Go back to created sheet

  • Thread starter Thread starter Don Guillett
  • Start date Start date
This macro creates a new sheet, lets call it "sheet1" to insert a pivot
table. Then it returns to the data sheet, let's call it "main" ,does clean
up, then stops. Since the new sheet, sheet1, may have different names all
the time, ie. sheet2, sheet3, etc..
How can I get the macro to go back to the new sheet? I need the code set up.
Also, at what code location do I insert the screenupdate=false to stop it
from flashing the screen?

Thanks.
 
Try some code like this:

Sub test()
Dim s As Worksheet

Set s = Sheets.Add
With s
.Range("A1").Value = "New sheet!"
End With

End Sub

Regarding application.screenupdating, it depends on when you want it to
happen. If you don't care about the user seeing anything going on, go ahead
and do it at the beginning of your macro. You'll have to determine the best
place for your purposes.

--
HTH -

-Frank Isaacs
Dolphin Technology Corp.
http://vbapro.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top