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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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