Help with a complicated macro

Busscheduler

New Member
Joined
Nov 23, 2020
Messages
41
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone, I am looking for help with a macro that will sort a list of guests that is dependent on what resort they are staying at and then open a new tab and place that information in a certain format. Here is the information that I am working with in Excel:

I apologize if I need to upload the spreadsheets. Please let me know and I will do that instead of jpegs.

Raw Data.png


The macro would need to sort each group by resort name, since the number of rows would change daily depending on how many guests they have that day, collect only the names for that resort and put them together in the format below.

Desired Result.png

I have limited skills when it comes to doing Macros, so any help would be greatly appreciated.
 
The code I provided assumes the data is in columns "R" "S" and "V"
it pastes the required data to columns "B" and "C" as per your original sample post.
However, the data you posted in post #9 is completely different from the original, so obviously wouldn't give the desired results !!
Yes, looking back at what I posted, it does look like that. My apologies for misleading you on that one.
I originally wanted to open a new tab and insert the information there. After thinking about it, I decided to forego the new tab and paste the information at the end of the current information. I altered the code a little to reflect the new columns:

VBA Code:
Sub MM1()
 Dim lr As Long, r As Long, x As Integer
 lr = Cells(Rows.Count, "R").End(xlUp).Row
     Cells(2, "R").Copy Cells(2, "AE")
 For r = 3 To lr + 1
    If Cells(r, "S") <> Cells(r - 1, "S") Then
        Cells(r, "S").Copy Cells(r, "AG")
    End If
 Cells(2, "S").Copy Cells(2, "AG")
 Cells(r - 1, "V").Copy Cells(r - 1, "AH")
 Next r
End Sub

The issue that I still have is in Column "R". I can only get the first time in cell R2 to copy and paste but I can't get any of the times below it to copy and paste. I've tried several different lines of code but I don't know how to advance it to R3 and R4 and so on. Could you help me with that? After that, the code is great and works fantastically.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Don't have EXcel at the moment, but shouldn't this line be referenceing col "R"
Rich (BB code):
If Cells(r, "S") <> Cells(r - 1, "S") Then

If Cells(r, "R") <> Cells(r - 1, "R") Then
 
Upvote 0
Don't have EXcel at the moment, but shouldn't this line be referenceing col "R"
Rich (BB code):
If Cells(r, "S") <> Cells(r - 1, "S") Then

If Cells(r, "R") <> Cells(r - 1, "R") Then
Michael M,
First, I want to apologize for my absence over the last 4 or 5 days. I was called out of town at the last minute and haven't had time to work on anything.
Second, you are correct that the original information that I sent did reference column "R". After I ran the macro a few times, and watched every step of the process, I changed some of the references.
Thank you very much for your help with this. I think that the foundation that you provided to get me started is working well and I will continue to work on this. I will mark this as solved for now, and I will hop back on if I need more help.

Thanks again Michael M and Alansidman for your assisstance.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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