Hello Good People!
I cannot for the life of my figure this one out, been trying for 3 days straight now so your help would be much appreciated.
I have a piece of code that imports data from another workbook. Bit ugly at certain points but this bit works fine.
Now I have 2 Sheets in the workbook called "Primary" and "Secondary" these have the same header and (can) have values under them in the range A4:G1000. What I want to do is merge the data from the two Sheets into a thrid one called "Combined". The way I tried to do this is first copy A4:G1000 from "Primary" to "Combined". So far so good.
Now comes the part that drives me crazy.
The sheet called "Secondary" contains formulas in the A4:G1000 range. These populate the rows if necessary, otherwise they return blank values.
I'm trying to copy the rows that have non-blank values in the sheet called "Secondary" (remember blanks have formulas) and paste them into the first blank row of the sheet called "Combined". (first blank because I've already imported rows from the "Primary" sheet).
I have tried a dozen codes already but not one of them worked so I won't bother pasting them here.
If any of you fine people have any suggestions for me I'd be eternally grateful.
Many thanks in advance!
I cannot for the life of my figure this one out, been trying for 3 days straight now so your help would be much appreciated.
I have a piece of code that imports data from another workbook. Bit ugly at certain points but this bit works fine.
Code:
Sub import()
Dim OpenFileName As String
Dim wb As Workbook
'Select and Open workbook
OpenFileName = Application.GetOpenFilename(",*.xlsm")
If OpenFileName = "False" Then Exit Sub
Set wb = Workbooks.Open(OpenFileName)
'Clear data
ThisWorkbook.Sheets("Quote Summary").Range("A5:CC1000").ClearContents
'Get Dashboard data
ThisWorkbook.Sheets("Dashboard").Range("L3").Value = wb.Sheets("P&L - IPCG2").Range("C15").Value
ThisWorkbook.Sheets("Dashboard").Range("J4").Value = wb.Sheets("P&L - IPCG2").Range("C16").Value
ThisWorkbook.Sheets("Dashboard").Range("J5").Value = wb.Sheets("Combined P&L").Range("C12").Value
ThisWorkbook.Sheets("Dashboard").Range("J6").Value = wb.Sheets("P&L - IPCG2").Range("C12").Value
ThisWorkbook.Sheets("Dashboard").Range("J8").Value = wb.Sheets("Combined P&L").Range("K11").Value
ThisWorkbook.Sheets("Dashboard").Range("J9").Value = wb.Sheets("P&L - IPCG2").Range("I36") + wb.Sheets("P&L - IPCG2").Range("I37") + wb.Sheets("P&L - IPCG2").Range("I40") + wb.Sheets("P&L - IPCG2").Range("I41") + wb.Sheets("P&L - IPCG2").Range("I63") + wb.Sheets("P&L - IPCG2").Range("I64") + wb.Sheets("P&L - IPCG2").Range("I69") + wb.Sheets("P&L - IPCG2").Range("I70") + wb.Sheets("P&L - IPCG2").Range("I71") + wb.Sheets("P&L - IPCG2").Range("I72") + wb.Sheets("P&L - IPCG2").Range("I75") + wb.Sheets("P&L - IPCG2").Range("I76") + wb.Sheets("P&L - IPCG2").Range("I98") + wb.Sheets("P&L - IPCG2").Range("I99") + wb.Sheets("P&L - IPCG2").Range("I104") + wb.Sheets("P&L - IPCG2").Range("I105")
'Get Quote Summary data
ThisWorkbook.Sheets("Quote Summary").Range("A4:CD1000").Value = wb.Sheets("Quote Summary - IPCG2").Range("A15:CD1000").Value
With ThisWorkbook.Sheets("Quote Summary").Range("A4:A1000")
.Replace "Y", ""
.Replace "#N/A", ""
.SpecialCells(xlBlanks).EntireRow.Delete
End With
wb.Close SaveChanges:=False
MsgBox ("done")
End Sub
Now I have 2 Sheets in the workbook called "Primary" and "Secondary" these have the same header and (can) have values under them in the range A4:G1000. What I want to do is merge the data from the two Sheets into a thrid one called "Combined". The way I tried to do this is first copy A4:G1000 from "Primary" to "Combined". So far so good.
Code:
Sub CopyPrimarytoCombined()
Worksheets("Port").Range("A1") = Worksheets("MPLS Port").Range("A1:G3")
Worksheets("Port").Range("A4:G1000").Value = Worksheets("MPLS Port").Range("A4:G1000").Value
End Sub
Now comes the part that drives me crazy.
The sheet called "Secondary" contains formulas in the A4:G1000 range. These populate the rows if necessary, otherwise they return blank values.
I'm trying to copy the rows that have non-blank values in the sheet called "Secondary" (remember blanks have formulas) and paste them into the first blank row of the sheet called "Combined". (first blank because I've already imported rows from the "Primary" sheet).
I have tried a dozen codes already but not one of them worked so I won't bother pasting them here.
If any of you fine people have any suggestions for me I'd be eternally grateful.
Many thanks in advance!