Enter date in cell

pete4monc

Board Regular
Joined
Jan 12, 2014
Messages
85
Office Version
  1. 365
Platform
  1. Windows
Hi guys
I have some vba that is button activated that looks in columns M and N and if there is a "Y" entered in a cell it copies the data in columns A,B,C etc to a spreadsheet with the same name as the column, then removes the "Y" and it all works fine.
But I'm stumbling, The below code inserts a date on the next available line when I need to put a date in column I in the active row as the corresponding "Y" before the vba deletes the "Y"?? (ie: if the "Y" is in cell "M5" it inserts the date in cell "I5" and not the next available row.
I hope the above makes sense?

Thanks guys

VBA Code:
 Application.ScreenUpdating = False
    Dim lCol As Long, sAddr As String, fnd As Range, x As Long, ws As Worksheet
    lCol = ActiveSheet.Cells(4, Columns.Count).End(xlToLeft).Column
    x = ActiveCell.Row
    Set fnd = Rows(x).Find("y", LookIn:=xlValues, lookat:=xlWhole)
    If Not fnd Is Nothing Then
        sAddr = fnd.Address
        Do
            Set ws = Sheets(Cells(4, fnd.Column).Value)
            [B]Sheets("CustomerService").Range("I" & Rows.Count).End(xlUp).Offset(1).Value = Now[/B]
            With ws
                Range("A" & x & ":G" & x).Copy .Cells(.Rows.Count, "A").End(xlUp).Offset(1)
            End With
            Set fnd = Rows(x).FindNext(fnd)
        Loop While fnd.Address <> sAddr
        sAddr = ""
    End If
    Application.ScreenUpdating = True
    
    Range("K5:U999").Select
    Selection.ClearContents
    Range("B2").Select
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try this

VBA Code:
Sheets("CustomerService").Range("I" & f.Row).Value = Now
 
Upvote 0
I have tried this code but it inserts the date in I2 every time and not in the I cell on the active row? Any ideas?
VBA Code:
Sheets("CustomerService").Range("I" & (ActiveCell.Rows.Count).End(xlUp).Offset(1).Value = Now
 
Upvote 0
Hi guys FYI
I have managed to sort it out I added this simple code into my original code.
VBA Code:
Range("I" & (ActiveCell.Row)).Select
        ActiveCell.Value = Date

Thanks to everyone especially @DanteAmor
 
Upvote 0
I'm glad to know that it already works for you.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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