Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Excel ignores VBA commands

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel ignores LocaleID? Sonnich Jensen Excel Discussion (Misc queries) 0 October 25th 11 03:33 PM
Excel 2007 ignores default printer preferences bob z Excel Discussion (Misc queries) 0 August 6th 08 06:51 PM
Excel commands Old Timer Excel Worksheet Functions 1 November 7th 06 03:15 AM
Excel ignores boot-time regional settings when interpreting a date [email protected] Excel Discussion (Misc queries) 2 November 4th 05 11:44 AM
Excel 2003 Macro ignores Arrow Keystrokes tss4info Excel Discussion (Misc queries) 0 May 5th 05 08:17 AM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"