question

Austin-2631 avatar image
0 Votes"
Austin-2631 asked

Excel VBA Button

I have a sheet that I would like to have a button on the top of every used column. When the button is pressed it should change the cell value in Row 8 for that Column to match cell B2 and it should change the value further down in the Column to match cell C2. Column A is a list of dates. The value that is further down needs to match the row with the date in cell A2. I was trying to use the match function to pull the row into VBA and use that row number to then write to the correct cell in the column. I am not very experienced with VBA so I am not sure what I am missing.

Private Sub CommandButton1_Click()
Var rowNum = Application.WorksheetFunction.Match(Range("A2"), Range("A10:A1000"))
Range("B8").Value = Range("B2").Value
Range("A" & rowNum&).Value = Range("C2").Value
End Sub

office-vba-devoffice-scripts-excel-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers