VBA, Store value in another sheet

Batteredburrito

New Member
Joined
Jul 31, 2018
Messages
15
Hi, I have the current VBA code to change the names within a sheet.

Code:
Private Sub ChangeNames_Click()

Dim Payer1 As String
Dim Payer2 As String

Payer1 = InputBox("Please enter a payers first name")
Payer2 = InputBox("Please enter a payers first name")

Range("a7").Value = Payer1
Range("a8").Value = Payer2

End Sub

Its currently set to store the values in cells A7 and A8 of the current sheet. I now need to offload this to a cells B2 and B3 to sheet 6 named Essential Info.

Im not sure how to properly reference the sheet and cells in the Range set. Any advice?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try
Code:
Private Sub ChangeNames_Click()
Dim Payer1 As String
Dim Payer2 As String
Payer1 = InputBox("Please enter a payers first name")
Payer2 = InputBox("Please enter a payers first name")
Sheets("Essential Info").Range("B2").Value = Payer1
Sheets("Essential Info").Range("B3").Value = Payer2
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,895
Messages
6,181,620
Members
453,057
Latest member
LE102024

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