Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
I'm trying to figure a way to compare the previous row with the target
row in a worksheet_SelectionChange event for example. if previous row < target.row then call macro else exit sub end if So my question is How would I go about determining the previous row? Any help would be great. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
Do you mean you want to compare the entire two rows to see if the contents are identical, or that you just want to compare the row
numbers ? -- Tim Williams Palo Alto, CA wrote in message oups.com... I'm trying to figure a way to compare the previous row with the target row in a worksheet_SelectionChange event for example. if previous row < target.row then call macro else exit sub end if So my question is How would I go about determining the previous row? Any help would be great. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
target.row-1 ?
not too sure what you are doing, are you wanting to check the selection and the previous selection are on the same row if so you'll need to keep track of the previous selection (or at least its row) in a static or module level variable. cheers Simon Blog: www.smurfonspreadsheets.net Website: www.codematic.net Excel development, support and training wrote in message oups.com... I'm trying to figure a way to compare the previous row with the target row in a worksheet_SelectionChange event for example. if previous row < target.row then call macro else exit sub end if So my question is How would I go about determining the previous row? Any help would be great. Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
I want to run my macro only if my new selection is on a different row
then my old selection. Target.Row - 1 won't work because my new selection could be any number of rows below or above my old selection. Target.Row - 1 would only refer to the row directly above the new selection. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
I'm new at VBA if I have to keep track of the previous row number in a
static or module level variable can someone walk me through it ? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
[1] Try putting a couple global variables at the top of the Workbook module,
like Public gOldRow as range Public gCurRow as range [2] In the worksheet_selection change event you need to capture the current row set gOldRow = gCurRow set gCurRow = Target.cells(1,1).entirerow [3] In the worksheet_change event code you can do like If gCurRow.row < cOldRow.row then ...... do updating ....... end if There are a variety of ways you can approach this. But this way you have a 'range' copy of the prior record and the current record to work with. " wrote: I'm new at VBA if I have to keep track of the previous row number in a static or module level variable can someone walk me through it ? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
need previous row help
Okay I tried that and got an Object Variable or With Block Variable
not set error. Any Ideas? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
3-Color Scale Vlookup for Current Month/Previous/Pre-Previous | Excel Discussion (Misc queries) | |||
why I can not see all my previous posts? | Excel Discussion (Misc queries) | |||
previous day | Excel Programming | |||
Looking at previous columns | Excel Programming | |||
Ref:Previous post | Excel Programming |