"variable" to make Macro not associated with one specific sheet in workbook

Hello,

I am recording a macro program in order to pull specific data points out a spreadsheet in excel. Currently the beginning of my macro looks like this:

Range("G20").Select
Selection.Copy
Sheets("Sheet1").Select
Range("C3").Select
ActiveSheet.Paste
Sheets("An32 CD45").Select

My problem comes with that last line of text. Does anyone know how I can insert some kind of variable or line of text that doesn't make this macro work only on sheet "An32 CD45" I want it to be able to pull the numbers from any page I ask, but when I try to run the macro on another page is still only pulls the numbers from "An32 CD45." Thank you for any help you can give.

Liz



Answer this question

"variable" to make Macro not associated with one specific sheet in workbook

  • TImBur

    Dim MySHeetName As String

    MySHeetName = InputBox("Enter Name of Sheet", "Title")

    Sheets(MySheetName).Select

    NOTE:OTP - Moving to VBA forum



  • "variable" to make Macro not associated with one specific sheet in workbook