button to add hits

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
I have a basic spreadsheet in sheet 1 and have added a button called 'First_Qtr_F_L' that when pressed is to send a '1' into the first available cell in column A in sheet 2.

When the button is pressed again, it should send another '1' into the next available cell in column A in sheet 2

and so on and so on.

This is the code I am using, but I know I have not written it correctly ...

Private Sub First_Qtr_F_L_Click()
Dim LR As Long
With Sheets("Sheet2")
LR = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & LR).Value = "1"
End With
End Sub

Can someone please amend it for me ?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I have a basic spreadsheet in sheet 1 and have added a button called 'First_Qtr_F_L' that when pressed is to send a '1' into the first available cell in column A in sheet 2.

When the button is pressed again, it should send another '1' into the next available cell in column A in sheet 2

and so on and so on.

This is the code I am using, but I know I have not written it correctly ...

Private Sub First_Qtr_F_L_Click()
Dim LR As Long
With Sheets("Sheet2")
LR = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & LR).Value = "1"
End With
End Sub

Can someone please amend it for me ?
G'day Chris

I can't see anything inherently wrong with your code and it works for me. However, if you want an alternative suggestion ...

<font face=Courier New><br><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> First_Qtr_F_L_Click()<br>    Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Value = 1<br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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