Excel VBA Run-time error '13' Type mismatch

rynxzard

New Member
Joined
Jan 13, 2014
Messages
2
I created a macro for a file but i am stuck on the line that was colored red
who can help me with this error.



Dim listSheetRange As Range
'Sheet to copy data From
Dim listSheet As Worksheet
'Sheet to copy data To
Dim actionSheet As Worksheet
Set listSheetRange = Worksheets("TRACKER").UsedRange
Set listSheet = Worksheets("TRACKER")
Set actionSheet = Worksheets("Daily HOLD")
'Clear the To Sheet
actionSheet.UsedRange.Clear
'Row 1 of From Sheet contains the data to match
'Copy Header Row i.e Row 2 of From Sheet
listSheet.Rows(1).Copy Destination:=actionSheet.Rows(1)
If UCase(listSheet.Columns(6)) = "HOLD" Then
listSheet.Columns(2).Copy Destination:=actionSheet.Columns(2)
listSheet.Columns(3).Copy Destination:=actionSheet.Columns(3)
listSheet.Columns(4).Copy Destination:=actionSheet.Columns(4)
listSheet.Columns(5).Copy Destination:=actionSheet.Columns(5)
listSheet.Columns(6).Copy Destination:=actionSheet.Columns(6)
listSheet.Columns(7).Copy Destination:=actionSheet.Columns(7)
listSheet.Columns(8).Copy Destination:=actionSheet.Columns(8)
listSheet.Columns(9).Copy Destination:=actionSheet.Columns(9)
listSheet.Columns(10).Copy Destination:=actionSheet.Columns(10)
End If

'hide any unwanted columns
actionSheet.Columns(1).Hidden = 1
actionSheet.Activate
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
It don't like trying to pick one value out of an entire column. Maybe a statement like this would work better.
Code:
If Application.CountIf(UCase(listSheet.Columns(6)), "HOLD") > 0 Then
This will allow VBA to look at the column to see if that value is there somewhere. If it is then then the other statements will execute, if not it will by pass the other statements.
 
Upvote 0
hello JLGWhiz still did not work..same error appears can, do you have another way to solve it?

thank you!
 
Upvote 0
hello JLGWhiz still did not work..same error appears can, do you have another way to solve it?

thank you!

Remove the UCase function.
Code:
If Application.CountIf(listSheet.Columns(6), "HOLD") > 0 Then
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top