Combining Defined Row and Defined Column

BalbasNiBarabas

New Member
Joined
Jun 1, 2020
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Hello guys!

So I am a beginner in VBA. I am actually just starting. I am a taking a course on it. So I have encountered a problem in this case:

What I need to do is:
1. Input row number and column letter in a separate Input box.
2. Get a value from (2,2) of a selection.
3. Put that value from (2,2) to the defined row number and column.


In my local, I can do the item 1 and 2. However, I am having a difficulty on doing the 3rd one. Below is my code:

VBA Code:
Sub Test()
Dim x As Integer, y As String, z As Double
x = InputBox("number:")
y = InputBox("letter:")
z = Selection(2, 2)
Range(x, y) = z
End Sub

I keep on having error on my range line. I how you can help me with this and give explanation.

Thanks!
BNB
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi & welcome to MrExcel.
Change it from Range to Cells.
 
Upvote 0
OMG @Fluff!!!

Thank you very much! It works perfectly. My new code is now:

VBA Code:
Sub Test()
Dim x As Integer, y As String, z As Double
x = InputBox("number:")
y = InputBox("letter:")
z = Selection(2, 2)
Cells(x, y) = z
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,324
Messages
6,124,249
Members
449,149
Latest member
mwdbActuary

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