Checkbox Macro

B

Ben in CA

Hello,

Here's a question that shows my ignorance when it comes to Excel macros.

How can I copy the data contained in one cell to the next cell on the same
row (without referencing the cell names in the macro) by pressing a checkbox?

How about leaving an empty column in between - copying from cell S2 to U2,
for instance?

Thanks in advance for anyone who has some ideas!
 
G

Gord Dibben

You will need event code behind the sheet.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "S1:S10" 'adjust to suit

Application.EnableEvents = False
On Error Resume Next
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
Target.Offset(0, 2).Value = Target.Value
End If
On Error GoTo 0
Application.EnableEvents = True
End Sub

Right-click on the sheet tab and "View Code". Copy/paste the above code
into that module.

Edit the range to suit. Alt + q to return to the Excel window.

Click on any cell in the S1:S10 range and the value will then be copied to
column U


Gord Dibben MS Excel MVP
 
B

Ben in CA

Thank you very much for your reply.

I might be able to use that the way it is, but is there a way I can have it
setup so that it only copies when I press a button or a checkbox?

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pasting cell contents into a macro 1
Help to create a macro 2
Macro + IF Function? 1
Automate Macro 3
How do I put a checkbox with no words? 2
sort macro 8
list and hyperlink 5
Help on Macro to hide empty rows 4

Top