Making a macro return to spreadsheet

  • Thread starter Thread starter Snoopy
  • Start date Start date
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
 
Hi Snoopy

Somewhere at the top of the routine insert

shtName = activeworkbook.name

and at the end put

sheets(shtname).select

Regards
Peter
 
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?
 
Dim myOrigRng as range

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

May work for you.
 
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
 
Back
Top