2

I am new to excel and using macros, how can i achieve below inquiry

How to add data to another column by pressing a button in excel?

When user press "SAVE", data from column B2 will be added to column of column F.

I tried to do below code but i doesn't work

Sub ButtonSave_Click()
Range("B2").Value = Range("F" & Row).Insert
End Sub

enter image description here

How to deal with this?

thanks in advance!

0

2 Answers 2

3

Use the following and replace Activesheet with the actual sheet name e.g. Worksheets("Sheet1")

Code:

Option Explicit
Public Sub ButtonSave_Click()
With ActiveSheet '<== replace with actual sheet reference
    .Range("F" & .Cells(.Rows.Count, "F").End(xlUp).Row + 1) = .Range("B2")
End With
End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

Hi QHarr, thank you for your answer, it works but it replaces the cells, i need is it adds up per row
Thanks a lot QHarr!
0
Row=Range("F1").End(xlDown).Offset(1,0).Row
Range("F" & Row).Value=Range("B2").Value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.