Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Right -- SpecialCells is independent of what is currently selected.
Have a look at your code with Jake Marx's comments in mind. I don't know why your code sometimes doesn't execute, but it is very likely that if you're relying on a cell or sheet being selected in order for your code to work, that's where things are going haywire. So instead of this: Selection.End(xlDown).Offset(1, 0).Select something more like this: Dim wb as Workbook dim ws as Worksheet set wb = TheWorkbookYouWantThisSetTo set ws = wb.TheWorksheetYouWantThisSetTo ws.Range("A1").End(xlDown).Offset(1,0).value = "whatever" I very rarely select anything in my code. Post back if you need clarification on anything or if you want us to look at more code. -- Dianne In , Gregg Roberts typed: Based on the help file, the SpecialCells method gives the same result whether the object it is used on is Cells or ActiveCell. I am using this exact same statement to get the row number of the last row of data in the "data" workbook, so I can test to see whether I have enough rows left in the destination workbook to my pasting, and it works consistently. Also, the statements being ignored are only ignored after they have been executed many times in a loop already. As I wrote, even the statement Range("A1").Select is also being ignored. The range of cells selected in the destination workbook/sheet stays selected after this statement is "executed." This is the level of weirdness that is happening. While I waited for an answer from the NG I changed my statement to: Selection.End(xlDown).Offset(1, 0).Select Again, the statement works for a while, and then stops working for no apparent reason. There are always eight columns in the copied range, hence no reason to test for that. Gregg |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel ignores LocaleID? | Excel Discussion (Misc queries) | |||
Excel 2007 ignores default printer preferences | Excel Discussion (Misc queries) | |||
Excel commands | Excel Worksheet Functions | |||
Excel ignores boot-time regional settings when interpreting a date | Excel Discussion (Misc queries) | |||
Excel 2003 Macro ignores Arrow Keystrokes | Excel Discussion (Misc queries) |