Results 1 to 7 of 7

Change log with command button

Threaded View

Hussainalieng Change log with command button 02-05-2022, 10:10 PM
BadlySpelledBuoy Re: Change log with command... 02-06-2022, 05:32 AM
Sintek Re: Change log with command... 02-06-2022, 07:26 AM
Hussainalieng Re: Change log with command... 02-06-2022, 06:12 PM
Sintek Re: Change log with command... 02-07-2022, 02:47 AM
Hussainalieng Re: Change log with command... 02-07-2022, 05:40 PM
Sintek Re: Change log with command... 02-08-2022, 02:32 AM
  1. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Change log with command button

    Small data set...no need for arrays...Here is a easy enough loop to understand...
    However, something tells me that there is more to this than meets the eye so to say...
    i.e. look at data5 in attached file...I added this after the first run of the macro...If Label6 does not yet exist the data will be entered into a new column and values entered just below...Does this not have to be entered into first new row based on column A?
    Anyway have a look and explain requirement in more detail...
    Private Sub CommandButton1_Click()
    Dim Fnd As Range, cell As Range, lc As Long, lr As Long, nr As Long
    With Sheets("Change_Log")
        For Each cell In Sheets("Data").UsedRange.SpecialCells(xlCellTypeConstants)
            If IsNumeric(cell) Then
                lc = .Cells(1, .Columns.Count).End(xlToLeft).Column + 1
                If lc = 2 Then
                    lc = 5
                Else
                    Set Fnd = .Rows(1).Find(cell.Offset(, -1).Value, , xlValues, xlWhole)
                    If Not Fnd Is Nothing Then lc = Fnd.Column
                End If
                .Cells(1, lc) = cell.Offset(, -1)
                nr = .Cells(.Rows.Count, lc).End(xlUp).Row + 1
                .Cells(nr, lc) = cell: If .Cells(nr, 1) = "" Then .Cells(nr, 1).Resize(, 3) = Array("Time Stamp", Date, Format(Now(), "HH:MM:SS"))
            End If
        Next cell
        .Activate
    End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Change command button color
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-26-2019, 04:19 PM
  2. How to change font size on an Active X controll button ("Command Button")
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-08-2017, 06:12 PM
  3. How to change the Command Button's cursor
    By CSLim in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-02-2013, 07:22 AM
  4. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  5. Change picture with command button
    By sumonrezadu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2012, 09:46 PM
  6. [SOLVED] using vba to change command button caption
    By PaulaO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2006, 02:40 PM
  7. Change Name of Command Button
    By comotoman in forum Excel General
    Replies: 2
    Last Post: 10-26-2005, 12:23 PM

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