Next Available Line

L

Legacy 436357

Guest
Hi,

Can this code be edited so it puts the data on the next available line? I sometimes need to delete some data.

Thanks

Code:
Private Sub CommandButton1_Click()
Static xCount As Integer
    Application.EnableEvents = False
    
        Range("J3").Offset(xCount, 0).Value = Range("H6").Value
        Range("K3").Offset(xCount, 0).Value = Range("H3").Value
        Range("L3").Offset(xCount, 0).Value = Format(Now(), "HH:MM:SS")
        xCount = xCount + 1
    
    Application.EnableEvents = True
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Thanks for replying. The first time I click the button it posts data on J3, K3, L3. Then on J4, K4, and L4 and so on. If I delete any rows it will still post to the last line it was posted and leave the deleted rows blank. I want it to post to the next blank row so there aren't gaps.
 
Upvote 0
If I delete any rows it will still post to the last line it was posted and leave the deleted rows blank.

so you're manually deleting the row?
if you right click > delete it will delete the entire row, thus not leaving a space.
or are you wanting the macro to paste the values in the blank row?
 
Upvote 0
I am running this code from a command button which pastes the data. If I click it more than once by accident it has duplicates of the same data. So I manually delete the duplicates.

Then when I click the button again it will paste the data below the deleted rows that were duplicates. Thus leaving blank rows.

I want to avoid having these blank rows please.
 
Last edited by a moderator:
Upvote 0
There is other information on the rows so it's not an option to delete the entire row.

Thank you
 
Upvote 0
There is other information on the rows so it's not an option to delete the entire row.

so you're deleting cells and not the rows?
I'm assuming you delete JxCount, KxCount, and LxCount?
Then you want to re-do the macro for the empty cells after changes are made to H3 and H6?

it would be extremely helpful if you could post an example using any of the tools provided here
so that i can get a clear picture of the data instead of asking a bunch of questions. As well as what you want the expected results to look like.

after prying information from you it sounds like after deleting duplicates in columns J, K, and L (manually)
you make a change to H3 and H6.
Then run the macro again to replace what you just deleted?
If thats the case please let me know
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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