• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Copy data from workbook

Hi Experts,

I would like to request Experts help modify “SendToMaster_Out” module at CopyWB workbook to allow data at Column E copied to MainData Workbook at Column F. Currently only Column A to D (CopyWB) are copied at MainData workbook. Hope Experts will help me to add this function.

  • 2
2 Solutions
Robert SchuttSoftware EngineerCommented:
Just a few code changes:

With shtMaster
  Set rngMaster = .Range(.Cells(3, 1), .Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, 6)) ' UPDATED TO 6
End With

With shtListing
  Set rngListing = .Range(.Cells(3, 1), .Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, 5)) ' UPDATED TO 5
End With

Open in new window

and in the copy data loop:
    rngMatch.Cells(IIf(i = 5, 6, i)).Value = rngWorking.Cells(i).Value ' UPDATED: fill column F with data from column E

Open in new window

Note: the loop already does i = 1 to 5
Another option: Use Columns instead of Cells
  'Copy Data
  For i = 1 To 4
    'Fill the first 4 Rows
    'This can be expanded easily to accomidate more data
    rngMatch.Columns(i).Value = rngWorking.Columns(i).Value
  Next i
  'Add Store information to Column 5 (E) in Master
  rngMatch.Columns(5).Value = IIf(shtListing.Name = "Outgoing", "Pending", "Done")
  'Copy E column to F Column(Main)
  rngMatch.Columns(6).Value = rngWorking.Columns(5).Value

Open in new window

CartilloAuthor Commented:

Thanks a lot for the help
CartilloAuthor Commented:
Hi robert_schutt,

Hope you'll consider this Q, intent to use the same solution for other workbook.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now