Hello,
I'm new to the forum and pretty new to excel VBA. I have a large spreadsheet and would like to filter it.
The spreadsheet has many columns, although only one I want to use for sorting. It is an integer value (Availability) and every time it changes compared to the previous row i'd like to record the change (i.e. copy the whole row with the new Availability figure and the previous row with the old Availability figure into a new spreadsheet).
I can run an autofilter, but now I don't know if there is a way I can access the row index of the filtered results easily in VBA? If so, that would make things easier.. Or any other suggestions of alternative approaches?
Would be very grateful for any assistance.
Many thanks,
tonypanda
Last edited by tonypanda; 01-26-2012 at 03:46 AM. Reason: solved
It would be good if you attach a sample file. Would only the availability column change or would other columns change?
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Ok, thanks. Example attached of what I'd like to do. example.xls
Ok, thanks. Example attached of what I'd like to do. Attachment 137682 hope this makes it clear!
All the other columns will be different, but I do need to retain that information - for example the date and time when the availability changed.
Last edited by tonypanda; 01-24-2012 at 04:14 AM.
Hey Tonypanda,
Use this code -Option Explicit Dim lrow As Long Dim i As Long Sub compare_rows() lrow = Worksheets(1).Range("A" & Rows.Count).End(xlUp).Row Worksheets(1).Rows("1:1").Copy Worksheets(2).Range("A1") For i = 2 To lrow - 1 If Worksheets(1).Range("C" & i).Value <> Worksheets(1).Range("C" & i + 1).Value Then Worksheets(1).Rows(i & ":" & i + 1).Copy Worksheets(2).Range("A" & Rows.Count).End(xlUp).Offset(1, 0) End If Next i End Sub
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Thanks a lot - works a treat!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks