Macro Problem

ironsides

Well-known Member
Joined
Aug 12, 2002
Messages
575
Im using this Macro
---------------------

Sub SpaceG()
'
' SpaceI Macro
' Macro recorded 10/6/2010 by DCS Valued Customer
'
' Keyboard Shortcut: Ctrl+Shift+G
'
'
Dim i As Long
For i = Range("G65536").End(xlUp).Row To 20 Step -1
If Cells(i, "G") <> Cells(i - 1, "G") Then Rows(i).EntireRow.Insert
Next i

End Sub

------------
The numerical value is cell G is derived thru this formula =Sum(F8-E8)/(E8)

I sort cell G and then try to activate the macro
But I get an error message
Runtime error 13 Type Mismatch

and the following is highlighted

If Cells(i, "i") <> Cells(i - 1, "i") Then

The cells in all cols are formatted Numbers 2 decimal places

Is the problem that Im using a formula in cell G to derive the value?
What adjustments can I make to get around this?

Im using Excel 2000

Thank you Ironsides
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
That looks like it should work. Maybe try

Code:
Sub SpaceG()
'
' SpaceI Macro
' Macro recorded 10/6/2010 by DCS Valued Customer
'
' Keyboard Shortcut: Ctrl+Shift+G
'
'
Dim i As Long
For i = Range("G65536").End(xlUp).Row To 20 Step -1
    If Cells(i, "G").Text <> Cells(i - 1, "G").Text Then Rows(i).Insert
Next i

End Sub
 
Upvote 0
That looks like it should work. Maybe try

Code:
Sub SpaceG()
'
' SpaceI Macro
' Macro recorded 10/6/2010 by DCS Valued Customer
'
' Keyboard Shortcut: Ctrl+Shift+G
'
'
Dim i As Long
For i = Range("G65536").End(xlUp).Row To 20 Step -1
    If Cells(i, "G").Text <> Cells(i - 1, "G").Text Then Rows(i).Insert
Next i

End Sub

Perfect Peter, Thanks yet again Matt
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,266
Members
452,902
Latest member
Knuddeluff

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