Mod Macro: Insert Bogus Values Into Empty Cells After Data, UP TO Row 101

jeffcoleky

Active Member
Joined
May 24, 2011
Messages
274
Excel 2016. Windows 10

I have an Excel macro that exports data into a file so that we can run a process on it. However the process we run the data against requires this exported file BE AT LEAST 101 rows of data for the process to work.

So I need help modifying this macro to automatically fill the remaining EMPTY rows with the bogus data below, up to line 101. Make sense?

PS. if there is no data in row A, then there won't be data in any of the other rows

Bogus data to input in empty rows up to row 101 (Col Letter):
A = "000 AAA"
B = "Bob Smith"
C = "Bob"
D = "Smith"
E = "123 Main"
F = "Smithfield"
G = "NC"
H = "50001"​

LINK to Google Spreadsheet Containing Before / After Sample Data is Here

Here's the current code to update:
Code:
Sub EXPORT_TO_MailMergeImportMe_CSV() ' Exports Mailmerge data to run Mail Merge Envelopes


  
    Application.Calculation = xlManual
    Application.DisplayAlerts = False
   
    Sheets("Mailmerge").Select
    
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    
    Set myrng = ActiveWindow.RangeSelection
    Set newbook = Workbooks.Add


    With newbook
    .Title = "MailMerge_ImportMe"
    .SaveAs FileName:="C:\temp\MailMerge_ImportMe.csv", FileFormat:=xlCSV
    End With
    
    myrng.copy
    Windows("MailMerge_ImportMe.csv").Activate
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
    Set Rangetoprocess = Range("A1:" & _
      Range("A" & Rows.Count).End(xlUp).Address)
    
    Application.ScreenUpdating = False
    
     For Each AnyCell In Rangetoprocess
       If AnyCell.Value = "" Then
       AnyCell.Value = "-"
       End If
     Next
    
    Set Rangetoprocess = Nothing
    
'// For Each row under 101 with no data in col A, FILL EMPTY ROWS WITH BOGUS DATA
'// How?
        
    Workbooks("MailMerge_ImportMe.csv").Save
    Workbooks("MailMerge_ImportMe.csv").Close
    On Error Resume Next
       
    Application.DisplayAlerts = True
    Application.Calculation = xlAutomatic
    Sheets("Mailmerge").Select
    Range("A2").Select
    Range("A1").Select


End Sub

Your assistance is MUCH appreciated
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try:
Code:
Sub FillBlankRows()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Range("A" & LastRow + 1 & ":H101") = Array("000 AAA", "Bob Smith", "Bob Smith", "123 Main", "Smithville", "NC", "50001")
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Beaten 2it
 
Last edited:
Upvote 0
Try:
Code:
Sub FillBlankRows()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Range("A" & LastRow + 1 & ":H101") = Array("000 AAA", "Bob Smith", "Bob Smith", "123 Main", "Smithville", "NC", "50001")
    Application.ScreenUpdating = True
End Sub

Wow! That was quick and painless. Thank you! exactly what I needed.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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