G
glensfallslady
I'm using this code to copy data from one workbook to another. If there is
data in B20:B57 I copy the data in Col A to Col B of the new WB and the Data
in Col B goes to Col c in the new WB.. Now I need to add another range to
it and I just can't get it to work. I've tried putting it before the copy and
even in a new sub, but it just isn't working. Now I need to copy the data
based on Col G20:G57. If there is data there I need to copy the data in col F
to Col B of the new WB and the Data in Col G to Col C. I appreciate your
help thanks.
Sub TodaySide()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range
With Worksheets("Data Input")
Set rng = .Range("B20:B57").SpecialCells(xlConstants, xlNumbers)
Set rng1 = Intersect(rng.EntireRow, .Columns(1))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
If Not rng Is Nothing Then
Else
Exit Sub
End If
End With
Dim bk As Workbook
Set bk = Workbooks.Open("C:\test\test.xls")
Set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)
rng1.Copy rng3.Offset(0, 0)
With Selection
.HorizontalAlignment = xlLeft
.Interior.ColorIndex = xlNone
End With
With Selection.Font
.Name = "Arial"
.Size = 9
.Bold = False
.ColorIndex = 0
End With
rng2.Copy rng3.Offset(0, 1)
With Selection
.Interior.ColorIndex = xlNone
End With
End Sub
data in B20:B57 I copy the data in Col A to Col B of the new WB and the Data
in Col B goes to Col c in the new WB.. Now I need to add another range to
it and I just can't get it to work. I've tried putting it before the copy and
even in a new sub, but it just isn't working. Now I need to copy the data
based on Col G20:G57. If there is data there I need to copy the data in col F
to Col B of the new WB and the Data in Col G to Col C. I appreciate your
help thanks.
Sub TodaySide()
Dim rng As Range, rng1 As Range, rng2 As Range
Dim rng3 As Range
With Worksheets("Data Input")
Set rng = .Range("B20:B57").SpecialCells(xlConstants, xlNumbers)
Set rng1 = Intersect(rng.EntireRow, .Columns(1))
Set rng2 = Intersect(rng.EntireRow, .Columns(2))
If Not rng Is Nothing Then
Else
Exit Sub
End If
End With
Dim bk As Workbook
Set bk = Workbooks.Open("C:\test\test.xls")
Set rng3 = bk.Worksheets("Pending").Cells(Rows.Count, 2).End(xlUp)(2)
rng1.Copy rng3.Offset(0, 0)
With Selection
.HorizontalAlignment = xlLeft
.Interior.ColorIndex = xlNone
End With
With Selection.Font
.Name = "Arial"
.Size = 9
.Bold = False
.ColorIndex = 0
End With
rng2.Copy rng3.Offset(0, 1)
With Selection
.Interior.ColorIndex = xlNone
End With
End Sub