Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro error why?
Spreadsheet contains a data range from cell A4 that is
refreshed regularly with updated data. Column A contains a list of cities and is sorted A-Z. I am trying to cretae macor that will insert a blank row between each change of city all the way down. Cuurent attempt as follows but does not work? Dim strstate As String strtate = ActiveCell ActiveCell("a4").Select Do If strstate = ActiveCell.Offset(-1, 0) Then ActiveCell.Offset(1, 0).Select Else rowSelection.Insert Shift:=xlDown ActiveCell.Offset(3, 0).Select Loop Until ActiveCell.Offset(2, 0) = Empty End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro error why?
Jaz, give this a try
Sub Insert_row() Application.ScreenUpdating = False Dim Rng As Range Dim x As Long Set Rng = Range("A4:A" & Range("A65536").End(xlUp).Row) For x = Rng.Rows.Count To 2 Step -1 If Rng.Cells(x, 1).Offset(-1, 0).Value < Rng.Cells(x, 1).Value Then Rng.Cells(x, 1).Resize(1, 1).EntireRow.Insert Shift:=xlDown End If Next x Application.ScreenUpdating = True End Sub -- Paul B Always backup your data before trying something new Using Excel 2000 & 97 Please post any response to the newsgroups so others can benefit from it ** remove news from my email address to reply by email ** "Jaz" wrote in message ... Spreadsheet contains a data range from cell A4 that is refreshed regularly with updated data. Column A contains a list of cities and is sorted A-Z. I am trying to cretae macor that will insert a blank row between each change of city all the way down. Cuurent attempt as follows but does not work? Dim strstate As String strtate = ActiveCell ActiveCell("a4").Select Do If strstate = ActiveCell.Offset(-1, 0) Then ActiveCell.Offset(1, 0).Select Else rowSelection.Insert Shift:=xlDown ActiveCell.Offset(3, 0).Select Loop Until ActiveCell.Offset(2, 0) = Empty End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro error why?
Try this
For x = 2 To 100000 If Range("A" & x) = "" Then Exit For If Range("A" & x) < Range("A" & x + 1) Then Range("A" & x + 1).Insert Shift:=xlDown x = x + 1 End If Next x -- "Jaz" wrote in message ... Spreadsheet contains a data range from cell A4 that is refreshed regularly with updated data. Column A contains a list of cities and is sorted A-Z. I am trying to cretae macor that will insert a blank row between each change of city all the way down. Cuurent attempt as follows but does not work? Dim strstate As String strtate = ActiveCell ActiveCell("a4").Select Do If strstate = ActiveCell.Offset(-1, 0) Then ActiveCell.Offset(1, 0).Select Else rowSelection.Insert Shift:=xlDown ActiveCell.Offset(3, 0).Select Loop Until ActiveCell.Offset(2, 0) = Empty End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Discussion (Misc queries) | |||
Macro Error | Excel Discussion (Misc queries) | |||
Macro error : Application-defined or object-defined error | Excel Discussion (Misc queries) | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) |