Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I just discovered something weird. I hope I can explain it clearly.
I have a Worksheet_Change event that, among other things, incrememts the last check number in column J: Range("I3").End(xlDown)(1, 2) = Application.Max(Range("J:J")) + 1 Occasionally I have reason to manually type in a check number in that column. If I do, the next time I trigger the Worksheet_Change event, the check number is NOT incremeted. Can anyone explain this, and hopefully point me to a fix? -- David |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without seeing your code, it is a little difficult. I knocked up a simple
test and it worked. -- HTH RP (remove nothere from the email address if mailing direct) "David" wrote in message ... I just discovered something weird. I hope I can explain it clearly. I have a Worksheet_Change event that, among other things, incrememts the last check number in column J: Range("I3").End(xlDown)(1, 2) = Application.Max(Range("J:J")) + 1 Occasionally I have reason to manually type in a check number in that column. If I do, the next time I trigger the Worksheet_Change event, the check number is NOT incremeted. Can anyone explain this, and hopefully point me to a fix? -- David |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob Phillips wrote
Without seeing your code, it is a little difficult. I knocked up a simple test and it worked. Thanks for responding. Well, I've worked it out. Recently, because I occasionally enter --- to indicate no check number for things like deposits, I formatted the column as Text to eliminate the apostrophe and that affected manually typed in check numbers that 'threw' the Worksheet_Change event. Formatting back to General fixed things. Can't have my cake and eat it, too <sigh. -- David |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are probably better off leaving the column formatted for General,
but you can have your cake and eat it to. To force XL to do a type conversion and then get the largest value in the column, use evaluate("Max(0+" & range(range("a1"),cells(rows.Count,1).end (xlup)).Address & ")") Do note that the Evaluate function has its own limitations. -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , dturner4_1999 @yahoo.com says... Bob Phillips wrote Without seeing your code, it is a little difficult. I knocked up a simple test and it worked. Thanks for responding. Well, I've worked it out. Recently, because I occasionally enter --- to indicate no check number for things like deposits, I formatted the column as Text to eliminate the apostrophe and that affected manually typed in check numbers that 'threw' the Worksheet_Change event. Formatting back to General fixed things. Can't have my cake and eat it, too <sigh. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tushar Mehta wrote
You are probably better off leaving the column formatted for General, but you can have your cake and eat it to. To force XL to do a type conversion and then get the largest value in the column, use evaluate("Max(0+" & range(range("a1"),cells(rows.Count,1).end (xlup)).Address & ")") Hmm... Elegant. However, after subbing "j1" for "a1" to match my check# column, substituted your Evaluate formula for existing offset reference, reformatted the column as Text, manually typed in a check # then ran the macro for next check and no increment :( Your offering does work if I don't manually enter a check# before running the macro. Further observation: If I highlight two check#'s above my target and autofill down one instead of manually typing the check#, then run the macro, things work no matter what the format. I'm obviously missing something. Lacking further clarification, I think I'll leave as General and go with Peter's Custom format and enjoy my cake. -- David |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In article , dturner4_1999
@yahoo.com says... Tushar Mehta wrote evaluate("Max(0+" & range(range("a1"),cells(rows.Count,1).end (xlup)).Address & ")") Hmm... Elegant. However, after subbing "j1" for "a1" to match my check# column, substituted your Evaluate formula for existing offset reference, reformatted the column as Text, manually typed in a check # then ran the macro for next check and no increment :( Did you also change the cells(rows.count,1) to cells(rows.count,10)? Or to the more transparent cells(rows.count,columns("J").column). -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , dturner4_1999 @yahoo.com says... Tushar Mehta wrote You are probably better off leaving the column formatted for General, but you can have your cake and eat it to. To force XL to do a type conversion and then get the largest value in the column, use evaluate("Max(0+" & range(range("a1"),cells(rows.Count,1).end (xlup)).Address & ")") Hmm... Elegant. However, after subbing "j1" for "a1" to match my check# column, substituted your Evaluate formula for existing offset reference, reformatted the column as Text, manually typed in a check # then ran the macro for next check and no increment :( Your offering does work if I don't manually enter a check# before running the macro. Further observation: If I highlight two check#'s above my target and autofill down one instead of manually typing the check#, then run the macro, things work no matter what the format. I'm obviously missing something. Lacking further clarification, I think I'll leave as General and go with Peter's Custom format and enjoy my cake. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Would value 0 in cells that don't need checking suffice. If so another way
to enjoy the odd bit of cake: Create a Custom number format like this General;General;"- - -" positive format ; negative format ; zero format Enter 0 instead of dashes to indicate no check. Regards, Peter T Well, I've worked it out. Recently, because I occasionally enter --- to indicate no check number for things like deposits, I formatted the column as Text to eliminate the apostrophe and that affected manually typed in check numbers that 'threw' the Worksheet_Change event. Formatting back to General fixed things. Can't have my cake and eat it, too <sigh. -- David |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter T wrote
Would value 0 in cells that don't need checking suffice. If so another way to enjoy the odd bit of cake: Create a Custom number format like this General;General;"- - -" positive format ; negative format ; zero format Enter 0 instead of dashes to indicate no check. That'll work --- thanks. -- David |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy Paste Wierdness | Excel Discussion (Misc queries) | |||
Application Look | Excel Discussion (Misc queries) | |||
macro to close excel application other than application.quit | Excel Programming | |||
application. ... | Excel Programming | |||
application.quit will not shut off application | Excel Programming |