Macro to populate blank cell(s) under given criterion

JC_Riptide

New Member
Joined
Mar 14, 2017
Messages
2
Hello,

I've recorded a few macros before and have done some light coding, but nothing too intense. I'm running into a problem where I'm trying to populate a blank cell in a row provided the user fills in values to the left of this field.

User will manually populate columns 1-11 on spreadsheet, and column 12 needs to populate a timestamp that is in a static position on the spreadsheet (cell F1). I'd like for the user to be able to populate multiple rows of their data (i.e. A3300 - K3300, A3301 - K3301), and the macro to timestamp the same static value to column 12 in multiple rows (up to the last row the user has populated data). The timestamp should be applied in the scenario that Column A has data and Column L is blank.

Here's the code I currently have - I'm not receiving any errors, but I think there's some circular reference in here that I'm not comprehending. I set i = 3 as the first two rows are locked with the button and timestamp field (=NOW() in Excel). Can you please assist?

Sub Timestamp()
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
TotesRow = Cells(Rows.Count, 12).End(xlUp).Row
For i = 3 To FinalRow
If Cells(i, 12).Value = "" Then
Cells(TotesRow + 1, 12).Value = Range("F1")
End If
Next i
End Sub


Thanks,
JC
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
If I understand correctly, shouldn't the timestamp be in row i, col "12" ??

Code:
Sub MM1()
Dim finalrow As Long, i As Long
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 3 To finalrow
    If Cells(i, 12).Value = "" Then
        Cells(i, 12).Value = Range("F1").Value
    End If
Next i
End Sub
 
Upvote 0
The timestamp should be applied in the scenario that Column A has data and Column L is blank.
Code:
        If [B][COLOR="#FF0000"]Cells(i, 12).Value[/COLOR][/B] = "" Then
            Cells(TotesRow + 1, 12).Value = Range("F1")
        End If
    Next i
End Sub
Here is a helpful little tip... the Cells object can take the column as either its number or its letter designation. So instead of this...

Cells(i, 12).Value

you could have used this...

Cells(i, "L").Value

and it would have worked as well.
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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