+ Reply to Thread
Results 1 to 3 of 3

Command Button - add data in adjacent cells

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    2

    Command Button - add data in adjacent cells

    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

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Command Button - add data in adjacent cells

    Try

    Please Login or Register  to view this content.
    Alternatively, consider to use "DATE" instead of "=TODAY()", so :
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Command Button - add data in adjacent cells

    I knew it would be something simple but I just couldn't see it!

    Thanks so much for getting back to me so quickly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1