OvernightSilver
New Member
- Joined
- Aug 9, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hey everyone!
I'm a complete novice to VBA but reasonably comfortable with Excel, and I'm having some difficulty compiling the different scripts that I've borrowed from others to do what I'm trying to do! Basically, I have a team that gets a big sheet of raw data from a lab, and they painstakingly rearrange and shuffle it to be in batches of 10 with a repeating header row between them, to easily give out to their team members. It takes the lead a good 30 minutes every morning just to prep the sheet, and I'm looking to help her out. The amount of data that comes in will be variable (could be 50, could be 200, likely never more than 250 though).
I started by setting up two sheets in the same workbook, sheet1 (raw data) and sheet2(output). I was able to modify a column copy script I found that copied over the entirety of the columns (including the header), which is great! I was also able to get them into the order that the lead uses (we only use some of the columns from the raw data, so I was able to copy raw data column B to output column C, D to X, etc. and grab all the required columns)
So now I have the data able to copy the columns over via the script, but I'm not sure how to break it into batches of 10 with a repeating header until the end of the raw data. The only slight wrinkle is the leads use a slightly modified header row (ie, not exactly the titles that the raw data comes with) but I'm not sure how hard that would be to add, and they can adjust to what the raw data title says if that's easier. You can see the header they use on the second preview below:
So what I'm looking for is help creating this, ideally:
Upload raw data into the sheet1 area, run the macro, sheet2 will output the desired reorganized columns with a repeating header every 10 rows until the raw data has no more entries
Here is an example of the Raw data:
And here is an example of the output I'm hoping for!
I can share the script I was able to throw together to copy the columns as well, for what it's worth! I'm using this but I'm not beholden to anything, because admittedly I do not know much about VBA yet. I was able to make a sheet that mostly did what I wanted through formulas in Excel, but it was messy and using a bunch of cell or table references made it tough
Used this script, repeating changing the source and target as needed to move all the columns around that we needed:
Sub CopyColumnToWorkbook()
Dim sourceColumn As Range, targetColumn As Range
Set sourceColumn = Worksheets("Sheet1").Columns("D")
Set targetColumn = Worksheets("Sheet3").Columns("B")
End Sub
I was found some threads referencing repeating headers, which I THINK I could get to work with my column copy script here, but I was hoping to kinda use the header the team wants if possible, but definitely not a requirement because the only I can see it (with my very narrow VBA knowledge!) is to have it saved somewhere that it gets referenced to create the headers. Which could be possible I suppose, a hidden third sheet?
Thank you so much for any assistance, and I will endeavor to answer any questions that people have. I only started learning how to do VBA maybe.....a week ago, so to say I am new to this is an understatement, but I will try!
I'm a complete novice to VBA but reasonably comfortable with Excel, and I'm having some difficulty compiling the different scripts that I've borrowed from others to do what I'm trying to do! Basically, I have a team that gets a big sheet of raw data from a lab, and they painstakingly rearrange and shuffle it to be in batches of 10 with a repeating header row between them, to easily give out to their team members. It takes the lead a good 30 minutes every morning just to prep the sheet, and I'm looking to help her out. The amount of data that comes in will be variable (could be 50, could be 200, likely never more than 250 though).
I started by setting up two sheets in the same workbook, sheet1 (raw data) and sheet2(output). I was able to modify a column copy script I found that copied over the entirety of the columns (including the header), which is great! I was also able to get them into the order that the lead uses (we only use some of the columns from the raw data, so I was able to copy raw data column B to output column C, D to X, etc. and grab all the required columns)
So now I have the data able to copy the columns over via the script, but I'm not sure how to break it into batches of 10 with a repeating header until the end of the raw data. The only slight wrinkle is the leads use a slightly modified header row (ie, not exactly the titles that the raw data comes with) but I'm not sure how hard that would be to add, and they can adjust to what the raw data title says if that's easier. You can see the header they use on the second preview below:
So what I'm looking for is help creating this, ideally:
Upload raw data into the sheet1 area, run the macro, sheet2 will output the desired reorganized columns with a repeating header every 10 rows until the raw data has no more entries
Here is an example of the Raw data:
Data Entry New Maco.xlsm | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | |||
1 | ID | OWNER ID | NAME | FIRST NAME | LAST NAME | DOB | GENDER | PHONE | ADDRESS | CITY | STATE | ZIP | Something | Race | Ethnicity | Something2 | LAB DATA | REGION 1 | OTHER REGION | LOCATION | IMPORT DATE | patient_type | STATUS | NOTES | DATA KNOWN | THIRD REGION | NAME2 | POS OR NEG | LAB DATA 2 | LAB DATE | ||
2 | --- | 90df8sd09f8sd098 | Batman Jones | Batman | Jones | 12/18/1993 | male | 3296768318 | 7692 Lectus St. | Los Angelos | CA | 12354 | --- | unknown | unknown | --- | CAS193849384398AK51 | Grantee | Region 1 Here | Location 1 here | 7/9/2021 | confirmed | open | Out of State | yes | Region 1 here | Batman Jones | positive | Test Lab 123 | 8/2/2021 | ||
3 | --- | 90df8sd09f8sd098 | Superman Jacobs | Superman | Jacobs | 6/8/1924 | female | 6801039284 | 248-2572 Dui Av. | Boston | MA | 45652 | --- | unknown | unknown | --- | CAS193849384398AK52 | Grantee | Region 2 here | Location 1 here | 7/10/2021 | confirmed | open | --- | yes | Region 2 here | Superman Jacobs | positive | Test Lab 456 | 8/7/2021 | ||
4 | --- | 90df8sd09f8sd098 | Aquaman Green | Aquaman | Green | 9/8/1929 | female | 1512971399 | 906-9672 Ac Street | Chicago | IL | 54654 | --- | unknown | unknown | --- | CAS193849384398AK53 | Grantee | Region 3 here | Location 2 here | 7/11/2021 | confirmed | open | --- | yes | Region 3 here | Aquaman Green | positive | Test Lab 789 | 8/5/2021 | ||
5 | --- | 90df8sd09f8sd098 | Deadpool Smith | Deadpool | Smith | 4/12/1941 | male | 9753755116 | Ap #714-9619 Nunc St. | Seattle | WA | 13247 | --- | unknown | unknown | --- | CAS193849384398AK54 | Grantee | Region 4 here | Location 3 here | 7/12/2021 | confirmed | open | --- | yes | Region 1 here | Deadpool Smith | positive | Test Lab 1122 | 8/5/2021 | ||
6 | --- | 90df8sd09f8sd098 | Jessica Jones | Jessica | Jones | 3/3/1964 | female | 4355720381 | 637-9857 Nunc Ave | Portland | OR | 87513 | --- | unknown | unknown | --- | CAS193849384398AK55 | Grantee | Region 1 Here | Location 1 here | 7/13/2021 | confirmed | open | --- | yes | Region 2 here | Jessica Jones | positive | Test Lab 1455 | 8/5/2021 | ||
7 | --- | 90df8sd09f8sd098 | Daredevil Davis | Daredevil | Davis | 1/11/1960 | female | 6806041615 | Ap #682-2158 In Ave | Flagstaff | AZ | 56467 | --- | unknown | unknown | --- | CAS193849384398AK56 | Grantee | Region 2 here | Location 1 here | 7/14/2021 | confirmed | open | --- | yes | Region 3 here | Daredevil Davis | positive | Test Lab 1788 | 8/5/2021 | ||
8 | --- | 90df8sd09f8sd098 | Chris St James | Chris | St James | 8/23/1953 | male | 6706363831 | 658 Non, Av. | Los Angelos | CA | 13571 | --- | unknown | unknown | --- | CAS193849384398AK57 | Grantee | Region 3 here | Location 2 here | 7/15/2021 | confirmed | open | --- | yes | Region 1 here | Chris St James | positive | Test Lab 2121 | 8/5/2021 | ||
9 | --- | 90df8sd09f8sd098 | Steve Austin | Steve | Austin | 6/30/1986 | female | 3047894012 | 3784 Leo, Street | Boston | MA | 75123 | --- | unknown | unknown | --- | CAS193849384398AK58 | Grantee | Region 4 here | Location 3 here | 7/16/2021 | confirmed | open | --- | yes | Region 2 here | Steve Austin | positive | Test Lab 2454 | 8/6/2021 | ||
10 | --- | 90df8sd09f8sd098 | Arnold Etchison | Arnold | Etchison | 1/31/1953 | female | 3010103266 | 794-2066 Lobortis Rd. | Chicago | IL | 54713 | --- | unknown | unknown | --- | CAS193849384398AK59 | Grantee | Region 1 Here | Location 1 here | 7/17/2021 | confirmed | open | --- | yes | Region 3 here | Arnold Etchison | positive | Test Lab 2787 | 8/5/2021 | ||
11 | --- | 90df8sd09f8sd098 | Axel Asher | Axel | Asher | 8/1/1996 | female | 6940444487 | Ap #279-8415 Aliquam St. | Seattle | WA | 65721 | --- | unknown | unknown | --- | CAS193849384398AK60 | Grantee | Region 2 here | Location 1 here | 7/18/2021 | confirmed | open | --- | yes | Region 1 here | Axel Asher | positive | Test Lab 3120 | 8/6/2021 | ||
12 | --- | 90df8sd09f8sd098 | Tex Thompson | Tex | Thompson | 1/29/1984 | female | 5086965446 | 265 Nisi Road | Portland | OR | 54621 | --- | unknown | unknown | --- | CAS193849384398AK61 | Grantee | Region 3 here | Location 2 here | 7/19/2021 | confirmed | open | --- | yes | Region 2 here | Tex Thompson | positive | Test Lab 3453 | 8/5/2021 | ||
13 | --- | 90df8sd09f8sd098 | Tike Alicar | Tike | Alicar | 10/26/2010 | female | 3367471005 | 9860 Elit, Av. | Flagstaff | AZ | 16752 | --- | unknown | unknown | --- | CAS193849384398AK62 | Grantee | Region 4 here | Location 3 here | 7/20/2021 | confirmed | open | Test Note here | yes | Region 3 here | Tike Alicar | positive | Test Lab 3786 | 8/5/2021 | ||
14 | --- | 90df8sd09f8sd098 | Lonnie Machin | Lonnie | Machin | 10/28/1978 | male | 3160229842 | 3097 Ac St. | Los Angelos | CA | 95423 | --- | unknown | unknown | --- | CAS193849384398AK63 | Grantee | Region 1 Here | Location 1 here | 7/21/2021 | confirmed | open | Yes | yes | Region 1 here | Lonnie Machin | positive | Test Lab 4119 | 8/4/2021 | ||
15 | --- | 90df8sd09f8sd098 | Victor Borkowski | Victor | Borkowski | 11/28/1924 | male | 2388719917 | 462 Suspendisse Road | Boston | MA | 11235 | --- | unknown | unknown | --- | CAS193849384398AK64 | Grantee | Region 2 here | Location 1 here | 7/22/2021 | confirmed | open | --- | yes | Region 2 here | Victor Borkowski | positive | Test Lab 4452 | 8/5/2021 | ||
16 | --- | 90df8sd09f8sd098 | Toni monetti | Toni | Monetti | 5/25/1999 | male | 6255119498 | Ap #794-673 In St. | Chicago | IL | 13542 | --- | unknown | unknown | --- | CAS193849384398AK65 | Grantee | Region 3 here | Location 2 here | 7/23/2021 | confirmed | open | --- | yes | Region 3 here | Toni monetti | positive | Test Lab 4785 | 8/5/2021 | ||
17 | --- | 90df8sd09f8sd098 | Jack Keaton | Jack | Keaton | 1/30/1930 | female | 9019069746 | P.O. Box 240, 5959 Nibh St. | Seattle | WA | 66541 | --- | unknown | unknown | --- | CAS193849384398AK66 | Grantee | Region 4 here | Location 3 here | 7/24/2021 | confirmed | open | --- | yes | Region 1 here | Jack Keaton | positive | Test Lab 5118 | 8/7/2021 | ||
18 | --- | 90df8sd09f8sd098 | Marc Slayton | Marc | Slayton | 9/18/1985 | male | 9881989763 | Ap #605-1650 Quis, Rd. | Portland | OR | 75215 | --- | unknown | unknown | --- | CAS193849384398AK67 | Grantee | Region 1 Here | Location 1 here | 7/25/2021 | confirmed | open | --- | yes | Region 2 here | Marc Slayton | positive | Test Lab 5451 | 8/7/2021 | ||
19 | --- | 90df8sd09f8sd098 | Sean Cassidy | Sean | Cassidy | 3/1/2013 | male | 3913618709 | 422-7148 In Rd. | Flagstaff | AZ | 77521 | --- | unknown | unknown | --- | CAS193849384398AK68 | Grantee | Region 2 here | Location 1 here | 7/26/2021 | confirmed | open | --- | yes | Region 3 here | Sean Cassidy | positive | Test Lab 5784 | 8/5/2021 | ||
20 | --- | 90df8sd09f8sd098 | Cassandra Lane | Cassandra | Lane | 9/25/1998 | female | 4363588416 | P.O. Box 125, 8429 Erat Av. | Los Angelos | CA | 33542 | --- | unknown | unknown | --- | CAS193849384398AK69 | Grantee | Region 3 here | Location 2 here | 7/27/2021 | confirmed | open | Test Note here | yes | Region 1 here | Cassandra Lane | positive | Test Lab 6117 | 8/5/2021 | ||
21 | ||||||||||||||||||||||||||||||||
22 | ||||||||||||||||||||||||||||||||
23 | ||||||||||||||||||||||||||||||||
Sheet1 |
And here is an example of the output I'm hoping for!
Data Entry New Maco.xlsm | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | |||
1 | ASSIGN | FIRST | LAST | DOB | LAB DATA | TEL | GENDER | RACE | ETHNICITY | STREET | CITY | ZIP | LAB | LAB DATE | ENTERED | CHECKED | NOTES | |||||
2 | Batman | Jones | 12/18/1993 | CAS193849384398AK51 | 3296768318 | male | unknown | unknown | 7692 Lectus St. | Los Angelos | 12354 | Test Lab 123 | 8/2/2021 | Out of State | ||||||||
3 | Superman | Jacobs | 6/8/1924 | CAS193849384398AK52 | 6801039284 | female | unknown | unknown | 248-2572 Dui Av. | Boston | 45652 | Test Lab 456 | 8/7/2021 | --- | ||||||||
4 | Aquaman | Green | 9/8/1929 | CAS193849384398AK53 | 1512971399 | female | unknown | unknown | 906-9672 Ac Street | Chicago | 54654 | Test Lab 789 | 8/5/2021 | --- | ||||||||
5 | Deadpool | Smith | 4/12/1941 | CAS193849384398AK54 | 9753755116 | male | unknown | unknown | Ap #714-9619 Nunc St. | Seattle | 13247 | Test Lab 1122 | 8/5/2021 | --- | ||||||||
6 | Jessica | Jones | 3/3/1964 | CAS193849384398AK55 | 4355720381 | female | unknown | unknown | 637-9857 Nunc Ave | Portland | 87513 | Test Lab 1455 | 8/5/2021 | --- | ||||||||
7 | Daredevil | Davis | 1/11/1960 | CAS193849384398AK56 | 6806041615 | female | unknown | unknown | Ap #682-2158 In Ave | Flagstaff | 56467 | Test Lab 1788 | 8/5/2021 | --- | ||||||||
8 | Chris | St James | 8/23/1953 | CAS193849384398AK57 | 6706363831 | male | unknown | unknown | 658 Non, Av. | Los Angelos | 13571 | Test Lab 2121 | 8/5/2021 | --- | ||||||||
9 | Steve | Austin | 6/30/1986 | CAS193849384398AK58 | 3047894012 | female | unknown | unknown | 3784 Leo, Street | Boston | 75123 | Test Lab 2454 | 8/6/2021 | --- | ||||||||
10 | Arnold | Etchison | 1/31/1953 | CAS193849384398AK59 | 3010103266 | female | unknown | unknown | 794-2066 Lobortis Rd. | Chicago | 54713 | Test Lab 2787 | 8/5/2021 | --- | ||||||||
11 | ASSIGN | FIRST | LAST | DOB | LAB DATA | TEL | GENDER | RACE | ETHNICITY | STREET | CITY | ZIP | LAB | LAB DATE | ENTERED | CHECKED | NOTES | |||||
12 | Tex | Thompson | 1/29/1984 | CAS193849384398AK61 | 5086965446 | female | unknown | unknown | 265 Nisi Road | Portland | 54621 | Test Lab 3453 | 8/5/2021 | --- | ||||||||
13 | Tike | Alicar | 10/26/2010 | CAS193849384398AK62 | 3367471005 | female | unknown | unknown | 9860 Elit, Av. | Flagstaff | 16752 | Test Lab 3786 | 8/5/2021 | --- | ||||||||
14 | Lonnie | Machin | 10/28/1978 | CAS193849384398AK63 | 3160229842 | male | unknown | unknown | 3097 Ac St. | Los Angelos | 95423 | Test Lab 4119 | 8/4/2021 | Test Note here | ||||||||
15 | Victor | Borkowski | 11/28/1924 | CAS193849384398AK64 | 2388719917 | male | unknown | unknown | 462 Suspendisse Road | Boston | 11235 | Test Lab 4452 | 8/5/2021 | Yes | ||||||||
16 | Toni | Monetti | 5/25/1999 | CAS193849384398AK65 | 6255119498 | male | unknown | unknown | Ap #794-673 In St. | Chicago | 13542 | Test Lab 4785 | 8/5/2021 | --- | ||||||||
17 | Jack | Keaton | 1/30/1930 | CAS193849384398AK66 | 9019069746 | female | unknown | unknown | P.O. Box 240, 5959 Nibh St. | Seattle | 66541 | Test Lab 5118 | 8/7/2021 | --- | ||||||||
18 | Marc | Slayton | 9/18/1985 | CAS193849384398AK67 | 9881989763 | male | unknown | unknown | Ap #605-1650 Quis, Rd. | Portland | 75215 | Test Lab 5451 | 8/7/2021 | --- | ||||||||
19 | Sean | Cassidy | 3/1/2013 | CAS193849384398AK68 | 3913618709 | male | unknown | unknown | 422-7148 In Rd. | Flagstaff | 77521 | Test Lab 5784 | 8/5/2021 | --- | ||||||||
20 | Cassandra | Lane | 9/25/1998 | CAS193849384398AK69 | 4363588416 | female | unknown | unknown | P.O. Box 125, 8429 Erat Av. | Los Angelos | 33542 | Test Lab 6117 | 8/5/2021 | --- | ||||||||
21 | ||||||||||||||||||||||
22 | ASSIGN | FIRST | LAST | DOB | LAB DATA | TEL | GENDER | RACE | ETHNICITY | STREET | CITY | ZIP | LAB | LAB DATE | ENTERED | CHECKED | NOTES | |||||
23 | ||||||||||||||||||||||
24 | ||||||||||||||||||||||
25 | ||||||||||||||||||||||
26 | ||||||||||||||||||||||
Sheet2 |
I can share the script I was able to throw together to copy the columns as well, for what it's worth! I'm using this but I'm not beholden to anything, because admittedly I do not know much about VBA yet. I was able to make a sheet that mostly did what I wanted through formulas in Excel, but it was messy and using a bunch of cell or table references made it tough
Used this script, repeating changing the source and target as needed to move all the columns around that we needed:
Sub CopyColumnToWorkbook()
Dim sourceColumn As Range, targetColumn As Range
Set sourceColumn = Worksheets("Sheet1").Columns("D")
Set targetColumn = Worksheets("Sheet3").Columns("B")
End Sub
I was found some threads referencing repeating headers, which I THINK I could get to work with my column copy script here, but I was hoping to kinda use the header the team wants if possible, but definitely not a requirement because the only I can see it (with my very narrow VBA knowledge!) is to have it saved somewhere that it gets referenced to create the headers. Which could be possible I suppose, a hidden third sheet?
Thank you so much for any assistance, and I will endeavor to answer any questions that people have. I only started learning how to do VBA maybe.....a week ago, so to say I am new to this is an understatement, but I will try!