ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Easy macro issue (I think) (https://www.excelbanter.com/excel-discussion-misc-queries/91089-easy-macro-issue-i-think.html)

punter

Easy macro issue (I think)
 

Hi,

I'm new to macros but getting pretty good at them. I put together a
macro that does various pivots. The problem arises after it runs the
first pivot (on which all the other data is eventually dumped). When I
wrote the macro the name of the sheet that opened up was Sheet2. When I
run the macro again I get an error if the sheet that is opened is not
named Sheet2. If it is named Sheet2 then it runs perfectly. Below is
the error I get:

Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Summary"

I assume that I need to put something inside the brackets to tell it to
proceed with whatever name the sheet is given once the pivot is run.
Does anyone know what I should do in this case.

Thanks for the help.

Eddie.


--
punter


------------------------------------------------------------------------
punter's Profile: http://www.excelforum.com/member.php...fo&userid=2044
View this thread: http://www.excelforum.com/showthread...hreadid=546440


Ardus Petus

Easy macro issue (I think)
 
Dim ws as worksheet

set ws = woksheets.add
ws.name="Summary"

HTH
--
AP

"punter" a écrit dans
le message de news: ...

Hi,

I'm new to macros but getting pretty good at them. I put together a
macro that does various pivots. The problem arises after it runs the
first pivot (on which all the other data is eventually dumped). When I
wrote the macro the name of the sheet that opened up was Sheet2. When I
run the macro again I get an error if the sheet that is opened is not
named Sheet2. If it is named Sheet2 then it runs perfectly. Below is
the error I get:

Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Summary"

I assume that I need to put something inside the brackets to tell it to
proceed with whatever name the sheet is given once the pivot is run.
Does anyone know what I should do in this case.

Thanks for the help.

Eddie.


--
punter


------------------------------------------------------------------------
punter's Profile:
http://www.excelforum.com/member.php...fo&userid=2044
View this thread: http://www.excelforum.com/showthread...hreadid=546440




punter

Easy macro issue (I think)
 

Thank you so much for the quick reply. Should I delete the two lines
currently in the macro and replace them with what you have listed
below? Or are they to be added to the two lines in some way?

Thanks

Eddie


--
punter


------------------------------------------------------------------------
punter's Profile: http://www.excelforum.com/member.php...fo&userid=2044
View this thread: http://www.excelforum.com/showthread...hreadid=546440


Ardus Petus

Easy macro issue (I think)
 
Replace lines currently in macro.

Cheers,
--
AP

"punter" a écrit dans
le message de news: ...

Thank you so much for the quick reply. Should I delete the two lines
currently in the macro and replace them with what you have listed
below? Or are they to be added to the two lines in some way?

Thanks

Eddie


--
punter


------------------------------------------------------------------------
punter's Profile:
http://www.excelforum.com/member.php...fo&userid=2044
View this thread: http://www.excelforum.com/showthread...hreadid=546440





All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com