Run-time error '13'

simplyeshu

New Member
Joined
Jun 25, 2011
Messages
30
Hello Frens,

I am trying to copy the content of few cells into the empty cells which are suppressed because of the same value but i am getting type mismatch error.

Below code i am using...

Sub Test()
For i=2 to (ActiveSheet.UsedRange.Rows.Count)
If Trim ((Cells(i,2) + Cells (i,6)+ Cells (i,8) + Cells (i,12) + Cells (i,17)+ Cells (i,25) + Cells (i,27) + Cells (i,29) + Cells (i,31) + Cells (i,33) + Cells (i,35 ))) = 0 Then
Range(Cells (i,2), Cells (i,35)).Select
Selection.FillDown
Range(Cells(i,42), Cells(i,42)).Select
Selection.FillDown
End If
Next
End Sub

Can anyone help me here?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
And have all those cells got numbers in them or letters? Or could they be either?
 
Upvote 0
I am getting error on the following line:

If Trim ((Cells(i,2) + Cells (i,6)+ Cells (i,8) + Cells (i,12) + Cells (i,17)+ Cells (i,25) + Cells (i,27) + Cells (i,29) + Cells (i,31) + Cells (i,33) + Cells (i,35 ))) = 0 Then Range(Cells (i,2), Cells (i,35)).Select

Some have numbers and some have letters
 
Upvote 0
Thank all for ur help.

I got it resolved now.

below is the code snippet for deleting empty rows and filling the data.

==================================
Sub My_Report()


'To delete empty rows

For i = 1 To ActiveSheet.UsedRange.Rows.Count

If Application.CountA(Range(Cells(i, 1), Cells(i, 42))) = 0 Then
ActiveSheet.Rows(i).Delete
End If
Next
'Fill the data
For i = 2 To (ActiveSheet.UsedRange.Rows.Count)

'If Trim((Cells(i, 2) + Cells(i, 6) + Cells(i, 8) + Cells(i, 12) + Cells(i, 17) + Cells(i, 25) + Cells(i, 27) + Cells(i, 29) + Cells(i, 31) + Cells(i, 33) + Cells(i, 35))) = 0 Then

If Application.CountA(Range(Cells(i, 1), Cells(i, 35))) = 0 Then

Range(Cells(i, 2), Cells(i, 35)).Select
Selection.FillDown
Range(Cells(i, 42), Cells(i, 42)).Select
Selection.FillDown
End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,588
Messages
6,179,743
Members
452,940
Latest member
rootytrip

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