Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Loop through 75 possible rows and copy cells from from one worksheet to another which is a template for a pre-printed form

$
0
0

Can this VBA macro be converted to Google sheets Scripts ? I have a worksheet that has 11 cells of data per row up to 75 rows (max). I loop through the rows and copy the cells to a template worksheet and then print the template for each row. The template worksheet was created using text boxes that match the pre-printed form perfectly. This VBA macro works perfect with Excel. Any help would be greatly appreciated !

Sub Copytotemplate()'    Dim LastRowSourceSheet  As Long    Dim SourceRowCounter    As Long    Dim Source              As Worksheet    Dim Destination         As Worksheet'    Set Source = Sheets("Driver list")    Set Destination = Sheets("Template")'    LastRowSourceSheet = Source.Range("A" & Rows.Count).End(xlUp).Row'    For SourceRowCounter = 3 To LastRowSourceSheet        Destination.TextBoxes("TextBox 12").Text = Source.Range("A" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 8").Text = Source.Range("C" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 1").Text = Source.Range("E" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 9").Text = Source.Range("H" & SourceRowCounter).Value        Destination.TextBoxes("TextBox 10").Text = Source.Range("J" & SourceRowCounter).Value        Destination.TextBoxes("TextBox 11").Text = Source.Range("L" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 2").Text = Source.Range("N" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 3").Text = Source.Range("P" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 4").Text = Source.Range("R" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 6").Text = Source.Range("T" & SourceRowCounter).Value         Destination.TextBoxes("TextBox 5").Text = Source.Range("V" & SourceRowCounter).Value'        Destination.PrintOut    NextEnd Sub

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>