+ Reply to Thread
Results 1 to 2 of 2

Macro, worksheet, from where did I come?

  1. #1
    Neal Zimm
    Guest

    Macro, worksheet, from where did I come?

    Hi - Am novice in VB.
    this is part of a macro I recorded to copy a range of cells.
    I was working in the temp worksheet, and the sheets temp select statement
    was based on my clicking.
    I'd like to generalize this section to copy the 'blank pg' cells from any
    worksheet.
    User would highlight cells on his current worksheet and execute the macro to
    copy back to his sheet. How do I find out the name of the sheet from whence
    I came?
    Code would be appreciated.

    The Go To dialog box did not give me this last location.
    How does something get into the Go To dialog box?

    Sheets("blank pg").Select
    ActiveCell.Range("A1:H20").Select
    Selection.Copy
    Sheets("temp").Select
    Selection.Insert Shift:=xlDown
    ActiveSheet.Paste
    Application.CutCopyMode = False


    Thanks much.
    Neal Z

  2. #2
    Neal Zimm
    Guest

    RE: Macro, worksheet, from where did I come?

    For other novices like me, I was able to dig out the answer myself. this code
    gets me back to the sheet I came from.

    Dim homesheet As Worksheet
    Set homesheet = ActiveSheet 'gets the name

    Sheets("different sheet").Select
    'code to do your thing on this sheet

    homesheet.Activate
    'get you back to from where you came.


    "Neal Zimm" wrote:

    > Hi - Am novice in VB.
    > this is part of a macro I recorded to copy a range of cells.
    > I was working in the temp worksheet, and the sheets temp select statement
    > was based on my clicking.
    > I'd like to generalize this section to copy the 'blank pg' cells from any
    > worksheet.
    > User would highlight cells on his current worksheet and execute the macro to
    > copy back to his sheet. How do I find out the name of the sheet from whence
    > I came?
    > Code would be appreciated.
    >
    > The Go To dialog box did not give me this last location.
    > How does something get into the Go To dialog box?
    >
    > Sheets("blank pg").Select
    > ActiveCell.Range("A1:H20").Select
    > Selection.Copy
    > Sheets("temp").Select
    > Selection.Insert Shift:=xlDown
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    >
    >
    > Thanks much.
    > Neal Z


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1