VBA to copy from one sheet to bottom of data on another sheet and re-sort

edokhotnik

Board Regular
Joined
Nov 10, 2010
Messages
104
I have two worksheets with similar data, but differing layouts. What is the way in VBA to copy certain data from Worksheet POAM to paste to the bottom of the range in Worksheet PermitRPT. Then re-sort Sheet PermitRPT alphabetically on Col A.

I have come up with formulas to do this, but would like to automate this many workbooks that have this format.

Thanks in advance for your assistance.

Ed

Excel Workbook
ABCDEFGHIJKL
1Finding #FindingFinalRatingRequirementID/Impact****Technical*StatusComments
21Widget brokenIABCD-1/HighDG-V001103Non-CompliantPreliminary Rating: I Words here 1
32Widget out of dateIIDEFG-1/MediumDG-V001213Non-CompliantPreliminary Rating: I More Words here 2
43Widget MissingIIHIJK-2/LowR-19385Non-CompliantPreliminary Rating: II Some More Words here 3
54Widget painted greenIIILMNO-1/LowRS-938Non-CompliantPreliminary Rating: III Even More Wordy Words here 4
6
POAM
Excel Workbook
ABCDEFG
1RequirementID**PrelimRatingFindingMitigationFinalRating
2ABCD-1INon-Compliant Preliminary Rating: I DG-V001103 Widget brokenWords here 1I
3DEFG-1INon-Compliant Preliminary Rating: I DG-V001213 Widget out of dateMore Words here 2II
4HIJK-2IINon-Compliant Preliminary Rating: II R-19385 Widget MissingSome More Words here 3II
5LMNO-1IIINon-Compliant Preliminary Rating: III RS-938 Widget painted greenEven More Wordy Words here 4III
6ABCD-1INon-Compliant Preliminary Rating: I DG-V001103 Widget brokenWords here 1I
7DEFG-1INon-Compliant Preliminary Rating: I DG-V001213 Widget out of dateMore Words here 2II
8HIJK-2IINon-Compliant Preliminary Rating: II R-19385 Widget MissingSome More Words here 3II
9LMNO-1IIINon-Compliant Preliminary Rating: III RS-938 Widget painted greenEven More Wordy Words here 4III
Excel 2010 PermitRpt
Excel 2010
Cell Formulas
RangeFormula
D2=MID(POAM!L2,FIND(":",POAM!L2)+2,FIND(CHAR(10),POAM!L2)-FIND(":",POAM!L2)-1)
D3=MID(POAM!L3,FIND(":",POAM!L3)+2,FIND(CHAR(10),POAM!L3)-FIND(":",POAM!L3)-1)
D4=MID(POAM!L4,FIND(":",POAM!L4)+2,FIND(CHAR(10),POAM!L4)-FIND(":",POAM!L4)-1)
D5=MID(POAM!L5,FIND(":",POAM!L5)+2,FIND(CHAR(10),POAM!L5)-FIND(":",POAM!L5)-1)
E2=POAM!K2&CHAR(10)&LEFT(POAM!L2,FIND(CHAR(10),POAM!L2))&POAM!I2&CHAR(10)&POAM!B2
E3=POAM!K3&CHAR(10)&LEFT(POAM!L3,FIND(CHAR(10),POAM!L3))&POAM!I3&CHAR(10)&POAM!B3
E4=POAM!K4&CHAR(10)&LEFT(POAM!L4,FIND(CHAR(10),POAM!L4))&POAM!I4&CHAR(10)&POAM!B4
E5=POAM!K5&CHAR(10)&LEFT(POAM!L5,FIND(CHAR(10),POAM!L5))&POAM!I5&CHAR(10)&POAM!B5
F2=MID(POAM!L2,FIND(CHAR(10),POAM!L2)+1,LEN(POAM!L2)-FIND(CHAR(10),POAM!L2)+1)
F3=MID(POAM!L3,FIND(CHAR(10),POAM!L3)+1,LEN(POAM!L3)-FIND(CHAR(10),POAM!L3)+1)
F4=MID(POAM!L4,FIND(CHAR(10),POAM!L4)+1,LEN(POAM!L4)-FIND(CHAR(10),POAM!L4)+1)
F5=MID(POAM!L5,FIND(CHAR(10),POAM!L5)+1,LEN(POAM!L5)-FIND(CHAR(10),POAM!L5)+1)
G2=POAM!C2
G3=POAM!C3
G4=POAM!C4
G5=POAM!C5
A2=LEFT(POAM!$D$2:$D$5,6)
A3=LEFT(POAM!$D$2:$D$5,6)
A4=LEFT(POAM!$D$2:$D$5,6)
A5=LEFT(POAM!$D$2:$D$5,6)
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
This will get your your last row, I'm pressed for time but from here you can
-> send it over to the other sheet with an sheets(sht).paste or something of that sort
-> for sorting i really don't know, try recording a macro of you sorting alphabetically

Code:
dim x as integer
dim r as integer
x = Selection.Range("A65536").End(xlUp).row
r = Cells(x, 1).Row
Rows(r).EntireRow.Copy

This code returns x as the last row of column 1 with anything in it.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,696
Members
452,938
Latest member
babeneker

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