C
Craig
I'm trying to copy information from one sheet to another in excel, and
I'm getting a type mismatch on a varialbe that I can't figure out.
Here's the code I have right now (I haven't had a chance to clean it up
yet).
Sub FindStatement()
Dim Xrow As Long
Dim Lrow As Long
Dim CurRow As Long
Dim cRange As Range
Dim sRange As Range
Dim R As Range
Dim BegDate As String
Dim EndDate As String
Dim myCust As String
Dim tDate As String
Dim tCust As String
Dim D As Range
Dim mRange As Range
Dim Zrow As Long
Dim Yrow As Long
Dim E As Range
Dim eRange As Range
Dim wRow As Long
Call TurnOff
Sheets("invoices").Activate
Xrow = Cells(Rows.Count, "A").End(xlUp).Row
Set cRange = Range("A1:Y" & Xrow)
cRange.Select
Selection.Copy
Sheets("statement data").Activate
[a3].Select
ActiveSheet.Paste
myCust = [e1].Value
BegDate = [c1].Value
EndDate = [c2].Value
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set sRange = Range("A4:A" & Lrow)
For Each R In sRange
R.Select
CurRow = R.Row
tCust = Range("C" & CurRow).Value
If myCust <> tCust Then Range("A" & CurRow).Value =
"XXDELETEXX"
Next R
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set sRange = Range("A4:A" & Lrow)
For Each R In sRange
CurRow = R.Row
tDate = Range("a" & CurRow).Value
If BegDate > tDate Then Range("A" & CurRow).Value =
"XXDELETEXX"
Next R
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set sRange = Range("A4:A" & Lrow)
For Each R In sRange
CurRow = R.Row
tDate = Range("a" & CurRow)
If EndDate < tDate Then Range("A" & CurRow).Value =
"XXDELETEXX"
Next R
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
For x = Lrow To 4 Step -1
If Range("a" & x).Value = "XXDELETEXX" Then Range("a" &
x).EntireRow.Delete
Next x
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set mRange = Range("a4:a" & Lrow)
For Each D In mRange
Sheets("statement4print").Activate
[b8].Select
wRow = Cells(Rows.Count & "b").End(xlUp).Offset(1, 0).Row
Range(wRow & ":" & wRow).Select
Selection.Insert shift:=xlDown
Sheets("statement data").Activate
Range("a" & D.Row).Select
Selection.Copy
Sheets("Statement4Print").Activate
Range("b" & wRow).PasteSpecial xlPasteValues
Sheets("Statement Data").Activate
Range("b" & D.Row).Select
Selection.Copy
Sheets("Statement4Print").Activate
ActiveSheet.Paste
Sheets("Statement Data").Activate
Range("u" & D.Row).Select
Selection.Copy
Sheets("Statement4Print").Activate
Range("g" & wRow).PasteSpecial xlPasteValues
Sheets("Statement Data").Activate
Next D
Sheets("Statement4Print").Activate
Call TurnOn
End Sub
I get the mismatch on
wRow = Cells(Rows.Count & "b").End(xlUp).Offset(1, 0).Row
Any ideas?
I'm getting a type mismatch on a varialbe that I can't figure out.
Here's the code I have right now (I haven't had a chance to clean it up
yet).
Sub FindStatement()
Dim Xrow As Long
Dim Lrow As Long
Dim CurRow As Long
Dim cRange As Range
Dim sRange As Range
Dim R As Range
Dim BegDate As String
Dim EndDate As String
Dim myCust As String
Dim tDate As String
Dim tCust As String
Dim D As Range
Dim mRange As Range
Dim Zrow As Long
Dim Yrow As Long
Dim E As Range
Dim eRange As Range
Dim wRow As Long
Call TurnOff
Sheets("invoices").Activate
Xrow = Cells(Rows.Count, "A").End(xlUp).Row
Set cRange = Range("A1:Y" & Xrow)
cRange.Select
Selection.Copy
Sheets("statement data").Activate
[a3].Select
ActiveSheet.Paste
myCust = [e1].Value
BegDate = [c1].Value
EndDate = [c2].Value
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set sRange = Range("A4:A" & Lrow)
For Each R In sRange
R.Select
CurRow = R.Row
tCust = Range("C" & CurRow).Value
If myCust <> tCust Then Range("A" & CurRow).Value =
"XXDELETEXX"
Next R
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set sRange = Range("A4:A" & Lrow)
For Each R In sRange
CurRow = R.Row
tDate = Range("a" & CurRow).Value
If BegDate > tDate Then Range("A" & CurRow).Value =
"XXDELETEXX"
Next R
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set sRange = Range("A4:A" & Lrow)
For Each R In sRange
CurRow = R.Row
tDate = Range("a" & CurRow)
If EndDate < tDate Then Range("A" & CurRow).Value =
"XXDELETEXX"
Next R
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
For x = Lrow To 4 Step -1
If Range("a" & x).Value = "XXDELETEXX" Then Range("a" &
x).EntireRow.Delete
Next x
Lrow = Cells(Rows.Count, "a").End(xlUp).Row
Set mRange = Range("a4:a" & Lrow)
For Each D In mRange
Sheets("statement4print").Activate
[b8].Select
wRow = Cells(Rows.Count & "b").End(xlUp).Offset(1, 0).Row
Range(wRow & ":" & wRow).Select
Selection.Insert shift:=xlDown
Sheets("statement data").Activate
Range("a" & D.Row).Select
Selection.Copy
Sheets("Statement4Print").Activate
Range("b" & wRow).PasteSpecial xlPasteValues
Sheets("Statement Data").Activate
Range("b" & D.Row).Select
Selection.Copy
Sheets("Statement4Print").Activate
ActiveSheet.Paste
Sheets("Statement Data").Activate
Range("u" & D.Row).Select
Selection.Copy
Sheets("Statement4Print").Activate
Range("g" & wRow).PasteSpecial xlPasteValues
Sheets("Statement Data").Activate
Next D
Sheets("Statement4Print").Activate
Call TurnOn
End Sub
I get the mismatch on
wRow = Cells(Rows.Count & "b").End(xlUp).Offset(1, 0).Row
Any ideas?