Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default type mismatch

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default type mismatch

Change the "&" in the cells statement to a ","
wRow = Cells(Rows.Count , "B").End(xlUp).Offset(1, 0).Row

HTH

Die_Another_Day
Craig wrote:
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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Type Mismatch Rockee052[_60_] Excel Programming 4 March 7th 04 12:12 AM


All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"