Hello!
I am VERY new to VBA (started learning about 3 days ago) but have created a code to look at a bunch of different cells on different sheets, and if there is a value in that cell, it will copy 3 other different cells in the doc and paste it to a coversheet. (Creating a button for employee timesheets that will grab the job number, cost code, and number of hours).My issue tis that I will need this code to run 1024 times, which would make a little less the 9500 lines of code . The main issue with all of that is that it obviously leads to an error for the procedure being too large. I'm trying to see if there is a way to streamline what I already have so that i can get this to run? Any help would be greatly appreciated!
Here is the code to reference 2 different cells, this process basically repeats over and over, but references different cells for the IF conditional, and the cells to be copied if the IF conditional is True.
I am VERY new to VBA (started learning about 3 days ago) but have created a code to look at a bunch of different cells on different sheets, and if there is a value in that cell, it will copy 3 other different cells in the doc and paste it to a coversheet. (Creating a button for employee timesheets that will grab the job number, cost code, and number of hours).My issue tis that I will need this code to run 1024 times, which would make a little less the 9500 lines of code . The main issue with all of that is that it obviously leads to an error for the procedure being too large. I'm trying to see if there is a way to streamline what I already have so that i can get this to run? Any help would be greatly appreciated!
Here is the code to reference 2 different cells, this process basically repeats over and over, but references different cells for the IF conditional, and the cells to be copied if the IF conditional is True.
VBA Code:
Private Sub Ret_Click()
If Not (IsEmpty(Sheet2.Range("C10"))) Then
Sheets("TS TIME CARD").Range("C5").COPY
Sheets("COVERSHEET").Range("G" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Sheets("TS TIME CARD").Range("C10").COPY
Sheets("COVERSHEET").Range("H" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Sheets("TS TIME CARD").Range("A10").COPY
Sheets("COVERSHEET").Range("I" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Else
End If
If Not (IsEmpty(Sheet2.Range("D10"))) Then
Sheets("TS TIME CARD").Range("D5").COPY
Sheets("COVERSHEET").Range("G" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Sheets("TS TIME CARD").Range("D10").COPY
Sheets("COVERSHEET").Range("H" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Sheets("TS TIME CARD").Range("A10").COPY
Sheets("COVERSHEET").Range("I" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Else
End If
EndSub