-
Oct 3rd, 2021, 09:54 AM
#1
Thread Starter
Addicted Member
-
Oct 4th, 2021, 01:13 AM
#2
Re: range testing
You run through the Cells A2 to E6
If none of those cells equals Range("E15") you're never going to set your Range to F2:F6, because it's in an If-ElseIf-construct
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 4th, 2021, 05:44 AM
#3
Re: range testing
i have no idea, from the description, what your end game is
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 4th, 2021, 08:44 AM
#4
Thread Starter
Addicted Member
Re: range testing
I start off by defining one range (a2:E6) and do a conditional test will cells A15 to E15
Then I want to define a new range (f2:F6) then conditional test with cell F:15
Zvoni is giving me a nudge or a hint . I can see that and I also know VBA is telling me that I set two ranges with the same name
I have tried to re-name the 2nd range and it does not work - VBA tells me that I have the range named twice - it has to be simple tweak of code but cannot get this code to behave the way I want to, I have looked for solutions all over the net but this programming (loops and conditionals) are my kyptonite.
Thanks again for the replies
Jeff
-
Oct 5th, 2021, 03:43 AM
#5
Re: range testing
there is no issue with using the same variable for 2 ranges, but not within a for each loop of the variable, as at that point the variable is locked
you do not actually nee to use a variable to loop through a range as you can do like
Code:
For Each cell In range("A2:e6")
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|