Excel macro to refer to a cell via a variable

Panos_user

New Member
Joined
Mar 21, 2011
Messages
1
Hi,

My name is Panos, I am new to the forum and excel as well. Currently I am using Windows Vista with excel 2007.
I have an excel file with several sheets. On the first sheet (summary page) there is a macro that creates new sheets, also letting users insert the name of that sheet in a pop-up box. The name of the sheet is saved to a variable called "ProjName".
What I am not able to do is write a macro that will take the value of the variable along with the content of a certain cell and put it back on the summary page. Can anyone please advice?
Please fine the code I am using below

Sub Project_Name()
Dim ProjName As String
ProjName = InputBox("Please enter your Project Name. Do not use special charactors such as !%$&*", "Project Name Entry Form", "Enter your Project Name here", 500, 700)
Sheets("Project Plan Template").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = ProjName
Worksheets(ProjName).Range("C2") = ProjName

'select first sheet/ find last row/ insert new row and copy values
Sheets("Current Projects").Select
Range("A1").Select
Range("B8:S8").Select
Selection.Copy
Cells(Cells(Rows.Count, "B").End(xlUp).Row + 1, "B").Select
ActiveSheet.Paste

'get value from ProjName variable and insert references
Cells(Cells(Rows.Count, "B").End(xlUp).Row, "B").Select
ActiveCell.FormulaR1C1 = "test"
Cells(Cells(Rows.Count, "C").End(xlUp).Row, "C").Select
ActiveCell.FormulaR1C1 = "='China Transport PUD'!R3C3"
Cells(Cells(Rows.Count, "D").End(xlUp).Row, "D").Select
ActiveCell.FormulaR1C1 = ProjName
Cells(Cells(Rows.Count, "E").End(xlUp).Row, "E").Select
ActiveCell.FormulaR1C1 = ProjName & "!R3C3"
End Sub

I tried testinga couple of ideas and the best i had are above. I hope that this only is a syntax error and not something more serious...

Thank you in advance for your help,

Regards,

Panos
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Basic syntax would be:
Code:
ActiveCell.FormulaR1C1 = "='" & ProjName & "'!R3C3"
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

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