VBA IF function: when two cells are different
Closed
LanLan
-
Nov 25, 2009 at 04:00 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Nov 27, 2009 at 07:26 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Nov 27, 2009 at 07:26 PM
Related:
- VBA IF function: when two cells are different
- Vba case like - Guide
- Mutator function c++ - Guide
- Network card function - Guide
- Hard drive function - Guide
- Excel online vba - Guide
2 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Nov 26, 2009 at 05:18 AM
Nov 26, 2009 at 05:18 AM
try this macro
Sub test()
Columns("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess
Dim j As Integer, k As Integer
j = Range("A1").End(xlDown).Row
'j is the last row
For k = j To 2 Step -1
If Cells(k, 1) <> Cells(k - 1, 1) Then
Range(Cells(k, 1), Cells(k + 1, 1)).EntireRow.Insert
End If
Next k
End Sub
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Nov 27, 2009 at 07:26 PM
Nov 27, 2009 at 07:26 PM
Try this slightly modified macro
when you invoke th macro
An input box will come up. fill in the initial cell address for e.g A10.
when you invoke th macro
An input box will come up. fill in the initial cell address for e.g A10.
Sub test()
Columns("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess
Dim j As Integer, k As Integer, m As Integer, r As String
r = InputBox("type the first cell under reference e.g. A10")
m = Range(r).Row
j = Range("A10").End(xlDown).Row
'j is the last row
For k = j To m + 1 Step -1
If Cells(k, 1) <> Cells(k - 1, 1) Then
Range(Cells(k, 1), Cells(k + 1, 1)).EntireRow.Insert
End If
Next k
End Sub
Nov 27, 2009 at 11:40 AM