Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi There,
I have a simple request but since my programming knowledge in VBA for excel is limited I don't really know where to start.
In excel, I have a column say A1:A100 which contains data that may or may not match. Basically I've sorted this data so all matching data is clumped.
What I want to do: Sorting and clumping aside, I'd like a macro that will look at the values in the column and if the value in A1 does not match in A2 to insert an entire row between A1 and A1. If the values do match, it should continue going down the column.
I hope this is enough information, thanks for your help in advance.
You could use a modification of the following code:
Const Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Public Function AddRows(prmRow As Range)
Dim c1 As String, c2 As String, c3 As String
Dim tgt As String
c1 = Mid(Letters, prmRow.Column, 1)
c2 = Mid(Letters, prmRow.Column + 2, 1)
c3 = CStr(prmRow.Row)
tgt = c1 & c3 & ":" & c2 & c3
ActiveSheet.Range(tgt).Insert xlShiftDown
End Function
This code inserts a blank row at [prmRow.Row], shifting everything in columns A through C down. It's just a quick-and-dirty test to teach me something new, so you may need to modify it severely to make it work for you."There are two things which are infinite: the universe and human stupidity - and I'm not so sure about the former." ~ Albert Einstein
Report Offensive Follow Up For Removal
Hi, I figured it out after just running through a few programming guides. I'm trained in C++ so I just needed to figure out the syntax. This is the code i used below.
Sub Spacing()
Dim Counter
Counter = 1
Do While Cells(Counter, 1) <> ""
Do Until Cells(Counter, 1) <> Cells(Counter + 1, 1)
Counter = Counter + 1
Loop
Cells(Counter + 1, 1).EntireRow.Insert Shift:=xlDown
Counter = Counter + 2
Loop
End Sub
Report Offensive Follow Up For Removal
![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |