VBA Plug data into the next available cell

martyloo

Board Regular
Joined
Sep 29, 2010
Messages
100
My code so far is.......

Sub Ace1_Click()
If IsEmpty(Range("B16")) Then
Range("B16") = 11
Else
Range("C16") = 11
End If
End Sub

All this does is if I press the relevant button "Ace1" it will display the value= 11 in cell B16, If i press this button again it will display the value=11 in cell C16, thats as far as my code goes.....

I would like it so if I press this button again it will display 11 in cell D16, if I press it again likewise cell E16, then cell F16... so on so forth

Not transferring the previous values. In the end if I click the button five times i want cells B16 C16 D16 E16 F16 all to have the value 11 in it.

Is this possible
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try

Code:
Sub Ace1_Click()
Dim NC As Integer
NC = WorksheetFunction.Max(2, Cells(16, Columns.Count).End(xlToLeft).Column + 1)
Cells(16, NC).Value = 11
End Sub
 
Upvote 0
But then you put a second question about going to the next empty column (e.g. D, E, F etc) and I answered that too, so if you combined the two answers it would achieve what you're asking here now.
 
Upvote 0
But then you put a second question about going to the next empty column (e.g. D, E, F etc) and I answered that too, so if you combined the two answers it would achieve what you're asking here now.

Oh really? I didnt't see, Thanks man I'll check again
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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