for next statement to check two different ranges

smokey4smokey

New Member
Joined
Mar 19, 2011
Messages
2
i have written some code to check a full range of cells and if an error is found lock excel into the incorrect cell.

one code works perfectly as the variable is the set of cells being checked however the second piece of code has me stuck as it is checking a totals column and i have managed to set an activecell select code but due to the type of sub im using (selection change) i cant get it to lock into the cell thats incorrect

i know its slightly vague but working on a mobile will try and paste code when at home next but any ideas would be appreciated
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Turn off macros at the top of your ws_selectionchange macro, then turn them back on when that macro is done doing it's work. See if that helps.
Code:
Private Sub Worksheet_SelectionChange(Byval Target As Range)
Application.EnableEvents = False

'your other code here

Application.EnableEvents = True
End Sub
 
Upvote 0
i already have those the issue is that in the first code it looks basically like

for each week1 in e8 to r31

case do hols 9 10 etc
else
week1 select

this works great

however in the second code im checking range w8 to w31 for impossible values that are generated by people who say are down to work 80 hours in a week when they cant work more than 40

the code looks like this

for each total1 in w8 to w31

case 1 2 3 4 etc
else
set r = activecell
activecell.select

the code for this is the same as above essentially but finding the incorrect cell in the second code is driving me nuts because the incorrect cell does not occur in the for each statement
 
Upvote 0
Guess I would need to see the workbook and then an explanation in the workbook of what/where something should happen,then I can examine the data, the instructions, and the code. Post the file somewhere and provide a link to it here...





...or use my signature link to send it to me at the address on my site.
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,522
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top