Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perphs stupid...
    I use sheets("test").range("A2:a2300").clearcontents.... .
    But how to use cells and row reference to have the same result?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use

    With Sheets("Test")
    .Range(.Cells(2, 1), .Cells(2300, 1)).ClearContents
    End With

    You can replace the numbers with variables if desired.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    Try

    Sheets(1).Range(Cells(1, 1), Cells(5, 3)).ClearContents
    Jerry

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Quote Originally Posted by Jezza View Post
    Sheets(1).Range(Cells(1, 1), Cells(5, 3)).ClearContents
    Jerry, that is dangerous if Sheets(1) is not the active sheet. Because Cells(1, 1) and Cells(5, 3) used without a sheet reference, they are assumed to be on the active sheet and hence the code will produce an error message.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    You could use

    With Sheets("Test")
    .Range(.Cells(2, 1), .Cells(2300, 1)).ClearContents
    End With

    You can replace the numbers with variables if desired.
    No dubt! You Are a genius!
    In effet is exactlly wath I need... I want to use var!
    You have read into my mind, how to'?

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by HansV View Post
    Jerry, that is dangerous if Sheets(1) is not the active sheet. Because Cells(1, 1) and Cells(5, 3) used without a sheet reference, they are assumed to be on the active sheet and hence the code will produce an error message.
    Gotcha, I was [stupidly] writing the code within Sheet 1 not a module
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •