Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 390
Default Macro basics

In , Dave Peterson
spake thusly:

Maybe just doing the equivalent of Data|ShowAll would be sufficient.


Okay, that's promising, but if all is already displayed, I get
an error. So I need an if-statement. Don't know how to formulate
it. Hoping you'll show me.

And you could use:

dim iCtr as long
dim wksNames as variant
wksnames = array(""2006 Realized - CSV Data", "Current - CSV Data")

for ictr = lbound(wksnames) to ubound(wksnames)
with worksheets(wksnames(ictr))
'do a bunch of stuff
end with
next ictr


Yes, that's excellent. It works well, once I figured out a
couple of critical things. First, I didn't know about

.Activate

but lucked out in finding it in the VBA Help pages when I
couldn't figure out why my directive to unprotect the sheet
wasn't working. Second, my query refresh wouldn't work and
caused a debug error once I inserted it into this "do stuff"
part of the loop. I flailed around for a while with Google
and help pages to no avail. When I was about to give up,
I finally tried this more or less by accident from the help
pages:

.QueryTables(1).Refresh BackgroundQuery:=False

and, lo! it worked. (What I'd ever want instead of (1),
I couldn't tell you.) :-)

N.B.: That was instead of this, which was suddenly barfing:
Selection.QueryTable.Refresh BackgroundQuery:=False

The macro still stops at the refresh and waits for me to
hit the Enter key to accept the name of the data source
that's correctly displayed in the pop-up window.
I would like it if it didn't wait for me to pound on the
Enter key. But that is not critical.

I suppose I also wouldn't mind a "do while" thing with the
variant instead of setting a counter, just as a matter
of style and to build my burgeoning macro know-how.

Okay, this thing is really starting to get somewhere!
Thanks, Dave.

Dallman Ross
 
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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


All times are GMT +1. The time now is 12:00 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"