Minggu, 29 Januari 2012

Re: [ExcelVBA] Re: VBA Is Putting Me In An Early Grave

 

Re the original post not appearing ... unlikely to be the editor you used,
would probably have been some other cause.

Re the particular Activate. I don't know why the activate would fail, but
it is certainly not needed. Deleting it would not have harmed the macro.

I'll have a look at why it would fail, at some time, but I wonder if the
open - when done from VBA - has done an internal conversion to an Excel
file, so that the window name has changed to "WildNewShoes.XLS" or xlsm.
Anyway, it's not needed, so ...

Activate vs Select. There are certainly differences, although I think they
are more at the cell level than at the window or sheet level. Personally, I
tend to Activate workbooks and sheets - purely because I am not "selecting"
them (for use in copy, etc). However, I doubt that it makes any difference
to the end results.

There are certainly times when you need to Select cells, rather than
Activate them (e.g. to select a range of cells), and Select will probably be
your default when dealing with cells and ranges.

Regards, Dave S

----- Original Message -----
From: "Michael Trombetta" <mickey11030@yahoo.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Monday, January 30, 2012 6:12 AM
Subject: [ExcelVBA] Re: VBA Is Putting Me In An Early Grave

My original post never appeared, perhaps because I used the rich text
editor. The code that caused the problem is:

Workbooks.Open Filename:="WildNewShoes.CSV"
Windows("WildNewShoes.CSV").Activate
Sheets("WildNewShoes").Select
Sheets("WildNewShoes").Move Before:=Workbooks("Analyze
WildNewShoes.xlsm").Sheets(1)

and, as I said, it was the Windows("WildNewShoes.CSV").Activate, statement
that caused the error. I deleted that statement and the code worked
perfectly.

Perhaps this is an appropriate time to ask the question: What is the
difference between Activate and Select? I notice, for example, that
Worksheet supports both Activate and Select.

Thanks for all your help,
Michael Trombetta

[Non-text portions of this message have been removed]

------------------------------------

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
here: http://www.mousetrax.com/techtrax to enter the ezine, then search the
ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------Yahoo! Groups Links

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1416 / Virus Database: 2109/4773 - Release Date: 01/28/12

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar