![]() |
Issue with With statement
Similar to another post I had put up today, I am now trying to "With" to
qualify my statements. However, the code below gives me the "Run Time error '1004': Application-defined or object defined error" error...any idea why? With Sheets("Open Transactions") .Range("D1").End(x1Down).Offset(1, 0).value = A.value End With -- Robert |
Issue with With statement
Copied your code into my own version and it doesn't appear to like having D1
or D2 empty. If these are empty using xldown sends it to Row 65536 (the bottom) and then trying to move down 1 row (by the offset) takes it out of the scope of the sheet. If these Cells are populated do not get the error message. "robs3131" wrote: Similar to another post I had put up today, I am now trying to "With" to qualify my statements. However, the code below gives me the "Run Time error '1004': Application-defined or object defined error" error...any idea why? With Sheets("Open Transactions") .Range("D1").End(x1Down).Offset(1, 0).value = A.value End With -- Robert |
Issue with With statement
There is probably a more sophisticated way but using your same code logic
With Sheets("Open Transactions") .Range("D65536").End(xlUp).Offset(1, 0).Value = A.Value End With This resolves your problem with having D1 or D2 blank. Note that this will not work if anywere midway down Column D is populated. "robs3131" wrote: Similar to another post I had put up today, I am now trying to "With" to qualify my statements. However, the code below gives me the "Run Time error '1004': Application-defined or object defined error" error...any idea why? With Sheets("Open Transactions") .Range("D1").End(x1Down).Offset(1, 0).value = A.value End With -- Robert |
Issue with With statement
Thanks David! I see now what the issue was. I think I'm just going to use
an If statement saying that if D1 / D2 are blank, then select the cell below. If they are not blank, then I'll use the logic I originally wrote. -- Robert "David Messenger" wrote: There is probably a more sophisticated way but using your same code logic With Sheets("Open Transactions") .Range("D65536").End(xlUp).Offset(1, 0).Value = A.Value End With This resolves your problem with having D1 or D2 blank. Note that this will not work if anywere midway down Column D is populated. "robs3131" wrote: Similar to another post I had put up today, I am now trying to "With" to qualify my statements. However, the code below gives me the "Run Time error '1004': Application-defined or object defined error" error...any idea why? With Sheets("Open Transactions") .Range("D1").End(x1Down).Offset(1, 0).value = A.value End With -- Robert |
All times are GMT +1. The time now is 01:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com