Making a macro return to spreadsheet

S

Snoopy

Hi fellows
My workbook is design to collect data from local files an put them
together as a "bigger" database. A number of spreadsheets in this
workbook contain each one single specific pivottable that reports on
its unique predesigned layout. By activating the same macro - using a
commandbutton on each spreadsheet (e.g pivot-table) all pivot-tables
updates.
My problem is to make the macro return to the spreadsheet from where
it was activated - and not expire on the last activated range/
spreadsheet.

My mission is not completed until this nagging problem is solved.

Will anybody kindly lead me out of this darkness and put some light in
to my Excel-VBA-life?

Loving regards
Snoopy
 
G

Guest

Hi Snoopy

Somewhere at the top of the routine insert

shtName = activeworkbook.name

and at the end put

sheets(shtname).select

Regards
Peter
 
S

Snoopy

Hi Snoopy

Somewhere at the top of the routine insert

shtName = activeworkbook.name

and at the end put

sheets(shtname).select

Regards
Peter








- Vis sitert tekst -

Thanks Peter, but the macro crashes on the "sheets(shtname).select" in
the end. What can be wrong?
 
D

Dave Peterson

Dim myOrigRng as range

set myorigrng = selection
'do lots of things
application.goto myorigrng

May work for you.
 
S

Snoopy

Dim myOrigRng as range

set myorigrng = selection
'do lots of things
application.goto myorigrng

May work for you.





Snoopywrote:





--

Dave Peterson- Skjul sitert tekst -

- Vis sitert tekst -

Dave
Fabulous!
You made the sun shine on a very rainy day

Regards
Snoopy
 

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

Top