I would like to create a loop to paste "online" in column N when the value is blank. Is that possible?
Asked
Active
Viewed 45 times
-1
-
1Yes, of course it is possible. – Feb 28 '16 at 07:35
-
do you have a sample or reference? – Bot Sundi Feb 28 '16 at 07:38
-
I have this script already: ActiveWorkbook.Sheets("medtour_enquiries").Range("N1:N1000000").AutoFilter 1, "=" My next step is to paste "online" on the filtered column – Bot Sundi Feb 28 '16 at 07:39
1 Answers
1
Try this code. I assume you know the last line in column N, otherwise you will have to change it to a do-while loop
Sub LoopN()
Dim i As Long
Dim n As Long
n = cells(rows.count, "N").end(xlup).row
For i = 1 To n
If Cells(i, 14).Value = "" Then Cells(i, 14).Value = "online"
Next i
End Sub

David912
- 378
- 1
- 2
- 11
-
A fairly standard method for returning the last populated cell in a column would be looking from the bottom up. Something like `n = cells(rows.count, "N").end(xlup).row` – Feb 28 '16 at 07:51
-
-
Here's mine: ActiveWorkbook.Sheets("medtour_enquiries").Range("N1:N1000000").AutoFilter 1, "=" ActiveWorkbook.Sheets("medtour_enquiries").Cells(2, 14).Copy ActiveWorkbook.Sheets("medtour_enquiries").Range("N2:N1000000").SpecialCells(xlCellTypeVisible).PasteSpecial ActiveWorkbook.Sheets("medtour_enquiries").AutoFilterMode = False What I want now is instead of copying the cell value: ActiveWorkbook.Sheets("medtour_enquiries").Cells(2, 14).Copy I want to copy a string example = MyString = "online" – Bot Sundi Feb 28 '16 at 07:55
-
It is more complicated to store a string in the clipboard, then simply putting it in a cell and then referencing it whenever you need. But if you insist then try reading here http://stackoverflow.com/questions/14219455/excel-vba-code-to-copy-a-specific-string-to-clipboard [ – David912 Feb 28 '16 at 08:55