copy data from single cell into merged different wkbs - part 2

Hi Experts

here is the link to the original question:-http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28145987.html

The new question is if I want to repeat the process for columns b, c, d, e, and f....from wkb1 to wkb2....as per my first question...
route217Asked:
Who is Participating?
 
NorieVBA ExpertCommented:
route217

It would still be good to know what cells are merged.

If you did just want to repeat the code I previously posted then this might work.
Sub CopyToMergedCellsMultiCols()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim rngSrc As Range
Dim rngDst As Range
Dim col As Long

       Set wb1 = Workbooks("Book1")
       Set wb2 = Workbooks("Book2")

       For col = 1 To wb1.Cells(2, Columns.Count).End(xlToLeft).Column

          Set rngSrc = wb1.Worksheets("Sheet1").Cells(2,col)
          Set rngDst = wb2.Worksheets("Sheet1").Cells(2,col)

          Do Until rngSrc.Value = ""
            rngDst.Value = rngSrc.Value
            Set rngSrc = rngSrc.Offset(1)
            Set rngDst = rngDst.Offset(1)
          Loop

       Next col

End Sub 

Open in new window

0
 
Saqib Husain, SyedEngineerCommented:
I wonder whether that macro works as explained in the question

If it does then try changing

       Set rngSrc = wb1.Worksheets("Sheet1").Range("A2")
       Set rngDst = wb2.Worksheets("Sheet1").Range("A2")

to
       Set rngSrc = wb1.Worksheets("Sheet1").Range("A2").resize(,6)
       Set rngDst = wb2.Worksheets("Sheet1").Range("A2").resize(,6)
0
 
route217Author Commented:
Hi ssaqibh

firstly thanks fir the feedback.  But I am getting a run time error 13...type miss match on line
do until rngSrc.value =""
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
route217Author Commented:
Using excel 2003....
0
 
Saqib Husain, SyedEngineerCommented:
Change it to

do until rngSrc.cells(1,1).value =""
0
 
route217Author Commented:
Ok ssaqibh

slight problem now the macro is copying the sixth cell value in wbk1 and pasting that into wkb2...as the merged cells in wkb2 are in rows of 6....

When the macro should be copying each cell value in rows a2:f until last ccell with value. ...into the merged cells corresponding range wkb2.
0
 
route217Author Commented:
Any ideas ssaqibh,??? And apologies if u are logged off taking 5 minutes.
0
 
NorieVBA ExpertCommented:
What cells are merged now?
0
 
route217Author Commented:
Hi imnorie

everything works fine I just want to repeat the process for the other colunns...as mentioned in the above question. ..
0
 
Saqib Husain, SyedEngineerCommented:
Can you upload a fake sample for testing?
0
 
route217Author Commented:
Ssaqibh give me an hour
0
 
route217Author Commented:
Apologies all

Imnorie...thanks it works perfectly fine
0
 
Saqib Husain, SyedEngineerCommented:
Are you sure mine works?
0
 
route217Author Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.