Hello I am trying to see if there is a way to combine these sub instead of having to do them separate. I want them together because I am wanting to add so the user selects two files (one that has sheet1, the other has sheet2) sheet1 is the copy file from and sheet2 is the paste in landing spots.
Please notice that in each sub the numbers for last col, 52, changes to 52 and also in .range the number 163 changes to 164 in the second sub and in the third sub it changes as well by adding one, i have others in which they change in those numbers as well. Any help would be grateful!
Sub name()
For i = 0 To 1
With Worksheets("Sheet1")
lastcol = .Cells(52 + i * 351, .Columns.Count).End(xlToLeft).Column
End With
If lastcol > 7 Then
With Worksheets("Sheet1")
inarr = .Range(.Cells(52 + i * 351, 7), .Cells(52 + i * 351, lastcol))
End With
If inarr(1, 1) <> "" Then
With Worksheets("Sheet2")
For j = 1 To UBound(inarr, 2)
jj = j - 1
.Range(.Cells(163 + jj * 11, 6 + i), .Cells(163 + jj * 11, 6 + i)) = inarr(1, j)
Next j
End With
End If
End If
Next i
End Sub
This brings in the address
Sub address()
For i = 0 To 1
With Worksheets("Sheet1")
lastcol = .Cells(53 + i * 351, .Columns.Count).End(xlToLeft).Column
End With
If lastcol > 7 Then
With Worksheets("Sheet1")
inarr = .Range(.Cells(53 + i * 351, 7), .Cells(53 + i * 351, lastcol))
End With
If inarr(1, 1) <> "" Then
With Worksheets("Sheet2")
For j = 1 To UBound(inarr, 2)
jj = j - 1
.Range(.Cells(164 + jj * 11, 6 + i), .Cells(164 + jj * 11, 6 + i)) = inarr(1, j)
Next j
End With
End If
End If
Next i
End Sub
Sub ID()
For i = 0 To 1
With Worksheets("Sheet1")
lastcol = .Cells(54 + i * 351, .Columns.Count).End(xlToLeft).Column
End With
If lastcol > 7 Then
With Worksheets("Sheet1")
inarr = .Range(.Cells(54 + i * 351, 7), .Cells(54 + i * 351, lastcol))
End With
If inarr(1, 1) <> "" Then
With Worksheets("Sheet2")
For j = 1 To UBound(inarr, 2)
jj = j - 1
.Range(.Cells(165 + jj * 11, 6 + i), .Cells(165 + jj * 11, 6 + i)) = inarr(1, j)
Next j
End With
End If
End If
Next i
End Sub
Please notice that in each sub the numbers for last col, 52, changes to 52 and also in .range the number 163 changes to 164 in the second sub and in the third sub it changes as well by adding one, i have others in which they change in those numbers as well. Any help would be grateful!
Sub name()
For i = 0 To 1
With Worksheets("Sheet1")
lastcol = .Cells(52 + i * 351, .Columns.Count).End(xlToLeft).Column
End With
If lastcol > 7 Then
With Worksheets("Sheet1")
inarr = .Range(.Cells(52 + i * 351, 7), .Cells(52 + i * 351, lastcol))
End With
If inarr(1, 1) <> "" Then
With Worksheets("Sheet2")
For j = 1 To UBound(inarr, 2)
jj = j - 1
.Range(.Cells(163 + jj * 11, 6 + i), .Cells(163 + jj * 11, 6 + i)) = inarr(1, j)
Next j
End With
End If
End If
Next i
End Sub
This brings in the address
Sub address()
For i = 0 To 1
With Worksheets("Sheet1")
lastcol = .Cells(53 + i * 351, .Columns.Count).End(xlToLeft).Column
End With
If lastcol > 7 Then
With Worksheets("Sheet1")
inarr = .Range(.Cells(53 + i * 351, 7), .Cells(53 + i * 351, lastcol))
End With
If inarr(1, 1) <> "" Then
With Worksheets("Sheet2")
For j = 1 To UBound(inarr, 2)
jj = j - 1
.Range(.Cells(164 + jj * 11, 6 + i), .Cells(164 + jj * 11, 6 + i)) = inarr(1, j)
Next j
End With
End If
End If
Next i
End Sub
Sub ID()
For i = 0 To 1
With Worksheets("Sheet1")
lastcol = .Cells(54 + i * 351, .Columns.Count).End(xlToLeft).Column
End With
If lastcol > 7 Then
With Worksheets("Sheet1")
inarr = .Range(.Cells(54 + i * 351, 7), .Cells(54 + i * 351, lastcol))
End With
If inarr(1, 1) <> "" Then
With Worksheets("Sheet2")
For j = 1 To UBound(inarr, 2)
jj = j - 1
.Range(.Cells(165 + jj * 11, 6 + i), .Cells(165 + jj * 11, 6 + i)) = inarr(1, j)
Next j
End With
End If
End If
Next i
End Sub