How to let the cell name be the worksheet name in the macro code?

Jesslynn

New Member
Joined
Jun 16, 2015
Messages
17
I want the user to input their own sheet name in cell E2. From there, the macro must be able to grab the value of the input into the code. Can anybody help me. Thank you in advance!

this is the part that I'm stuck at :(


Dim x As Workbook

x.Sheets(Range(E2)).Rows(i).Columns("D")
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Do you mean
Code:
x.Sheets(Range("E2").value)
but what is this for ?

Code:
Rows(i).Columns("D")

Maybe you should post ALL of the code !!
 
Upvote 0
the user would write the sheetname of wkbk x in Cell E2
The macro in wkbk x must be able to select the sheetname that is written in E2

Dim x As Workbook
Dim y As Workbook
Set x = Workbooks.Open("")
Set y = Workbooks.Open("")

'From here i do not know the sheet name of the workbook but it is written in workbook x
'The next step I'm doing is copying the x file and paste it in y file

x.Sheets("???").Rows(1).Columns("G").Copy Destination:=y.Sheets("Sheet1").Rows(1).Columns("C")

The sheetname is in the excel sheet.


How do I let the Value in Cell E2 be the sheetname in macro without manually keying into the code above?
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top