Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50068

Command Button - add data in adjacent cells

$
0
0
Hi all,

I'm almost entirely new to using VBA (aside from dabbling in it about twelve years ago, 99% of which I have forgotten!), so forgive me if this is a really stupid question.

I have a command button on a UI that, when pressed, needs to enter a date in column A, and text in the adjacent cells in columns B and C. This is what I currently have:

Private Sub btnLR_Click()
Sheets("TODAY").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Value = "=TODAY()"
Sheets("TODAY").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0).Value = "X"
Sheets("TODAY").Cells(Rows.Count, "C").End(xlUp).Offset(1, 0).Value = "Y"
End Sub

It works fine until it encounters a filled cell in column B with empty cells in columns A and C. When that happens, the entries are no longer in adjacent cells. What do I need to do to ensure that every time I press the button the data will always be entered in adjacent cells across a row, regardless of what empty/filled cells are above it?

Many thanks,

Fee

Viewing all articles
Browse latest Browse all 50068

Trending Articles