VBA code to enter number in a selected cell

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,699
I have a table in my spreadsheet that gets rows added to it as needed. I want to put a 1.1 into cell AB for a given row. This is to occur when the row is selected and a button pressed. Can someone help me please?
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

vcoolio

Well-known Member
Joined
Jun 29, 2014
Messages
1,001
Hello DPaton,

Try the following code:-


Code:
Sub Test()

Dim Check As String

Check = MsgBox("The value 1.1 will be placed in the corresponding cell of Column AB of this row.", vbOKCancel)
If Check = vbCancel Then Exit Sub

With Sheet1.ListObjects("Table1").DataBodyRange  '----> Change sheet name and table name to suit.
           Selection.Columns(28).Value = 1.1
End With

End Sub

I hope that this helps.

Cheerio,
vcoolio.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,501
Messages
5,523,290
Members
409,508
Latest member
Afc

This Week's Hot Topics

Top