none
How to get value from Merged cells in Excel using VBA?

    Question

  • I wish to copy one value from file1 sheet1 to file2 sheet1.

    I had some value at file1 sheet1 is manual merge cell, so i cant get the value.

    How can i get the value from the merge cell?

    My coding is as below:

     ActiveSheet.Cells(Target.Row, Col_File_A_First) = Workbooks(myFileB).Worksheets(mySheetB).Cells(rFind1.Row, Col_File_B_First)


    Appreciate for the help..Thnx.




    • Edited by brownie yeo Thursday, December 29, 2011 4:32 AM
    Thursday, December 29, 2011 2:28 AM

All replies

  • On Thu, 29 Dec 2011 02:28:14 +0000, brownie yeo wrote:
     
    >
    >
    >I wish to copy one value from file1 sheet1 to file2 sheet1.
    >
    >I had some value at file1 sheet1 is manual merge cell, so i cant get the value.
    >
    >How can i get the value from the merge cell?
    >
    >My coding is as below:
    >
    > ActiveSheet.Cells(Target.Row, Col_File_A_First) = Workbooks(myFileB).Worksheets(mySheetB).Cells(rFind1.Row, Col_File_B_First)
    >
    >Appreciate for the help..Thnx.
    >
     
    The contents of a merged cell range can be obtained from the upper left hand cell of the merged area.
    I cannot comment on your code snippet.
     

    Ron
    Thursday, December 29, 2011 4:17 AM
  • Thnx for ur reply, Ron.

    If here, can edit my code?

      ActiveSheet.Cells(Target.Row, Col_File_A_First) = Workbooks(myFileB).Worksheets(mySheetB).Cells(rFind1.Row, Col_File_B_First)


    Thursday, December 29, 2011 4:35 AM
  • On Thu, 29 Dec 2011 04:35:11 +0000, brownie yeo wrote:
     
    >
    >
    >Thnx for ur reply, Ron.
    >
    >If here, can edit my code?
    >
    >  ActiveSheet.Cells(Target.Row, Col_File_A_First) = Workbooks(myFileB).Worksheets(mySheetB).Cells(rFind1.Row, Col_File_B_First)
    >
    >
    >
    As I just wrote:
     
    >I cannot comment on your code snippet.
     
    In the context of your question, your snippet is not comprehensible to me.  So I would suggest you study HELP for further information on merged cells, and then apply the information I have provided.
     
    By the way, this difficulty of working with merged cells is why many avoid them.
     

    Ron
    Thursday, December 29, 2011 12:13 PM