Using a module when recording a macro

Ghais Chatila

New Member
Joined
Aug 7, 2009
Messages
30
Hello,

i am recording a macro that rearranges some cells, then i want it to add a blank row after each distinct entry in the first column (SEE BELOW EXAMPLE)

1670342774812.png


I found below code to add blank row. How can i integrate this code into a macro that i will record, or after recording it.


1670342921147.png
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Just before the End Sub of your recorded macro add: Call InsertRowsAtValueChange
 
Upvote 0
Where did you paste the macro you showed in post #1 ? It goes in a Standard module.
 
Upvote 0
Cut/paste the macro you showed in post #1 from where it is now located to below the macro you showed in post #3 and launch this second macro.
 
Upvote 0
Hello

i am not sure why this is still giving me an error... when i run the macro, i get an error and the cursor is highlighted where i put a bunch of stars. Please help

Sub AC_tab_Matchup()
'
' AC_tab_Matchup Macro
'

'
ActiveCell.Range("A1:A32").Select
Selection.Cut
ActiveCell.Offset(0, -1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, 11).Range("A1:A32").Select
Selection.Cut
ActiveCell.Offset(0, -10).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, 12).Range("A1:A32").Select
Selection.Cut
ActiveCell.Offset(0, -10).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Range("A1:I32").Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(1, -3).Range("A1:A31").Select
Selection.NumberFormat = "m/dd/yy;@"
ActiveCell.Offset(0, 2).Range("A1:A31").Select
Selection.NumberFormat = "m/dd/yy;@"
ActiveWindow.LargeScroll ToRight:=-1
ActiveCell.Offset(-1, -6).Range("A1:G32").Select
ActiveWorkbook.Worksheets("AC").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("AC").Sort.SortFields.Add2 Key:=ActiveCell.Range( _
"A1:A31"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("AC").Sort
.SetRange ActiveCell.Offset(-1, 0).Range("A1:G32")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
*************
Sub InsertRowsAtValueChange()
'Update by Extendoffice
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
For i = WorkRng.Rows.Count To 2 Step -1
If WorkRng.Cells(i, 1).Value <> WorkRng.Cells(i - 1, 1).Value Then
WorkRng.Cells(i, 1).EntireRow.Insert
End If
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
This a completly different problem and topic so you should open a new thread for this.
Anyway, there are two macros in the code you posted and the first has at least a missing End Sub as your editor clearly informs you.
 
Upvote 0

Forum statistics

Threads
1,214,859
Messages
6,121,963
Members
449,059
Latest member
oculus

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