Consulting

Results 1 to 8 of 8

Thread: finding the value and paste in another sheet .

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    358
    Location

    finding the value and paste in another sheet .

    Hello
    I need your help , I have a list that the weight column are not static mean it is in different column i need find the weight column from sheet 1 and garb the value after weight column and paste them in sheet 2 as the below sample .
    you can see it in attached images . i need VBA that can do it automatically .
    really appreciate for your help and time .

    Attachment 20953
    Attached Images Attached Images
    Last edited by parscon; 11-14-2017 at 04:03 AM.

  2. #2
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,396
    Location
    Start wirh
    Dim FoundSrc As Range
    Dim FoundDest as Range
    
    Set FoundSrc = Sheet1.Rows(1).Find("Weight(kg)")
    Set FoundDest = Sheet2.Rows(1).Find("Weight(kg)")
    If not FoundSrc is Nothing And Not FoundDest is Nothing then
    FoundDest.Offset(,1) = FoundSrc.Offset(,1)
    You might have to edit the Find Parameters.
    Please take the time to read the Forum FAQ

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    358
    Location
    Thanks you so much for your help but our sheet2 is empty and must paste the data that found to sheet2 .

  4. #4
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,396
    Location
    Research the offered code and adjust as needed.
    Please take the time to read the Forum FAQ

  5. #5
    VBAX Tutor MINCUS1308's Avatar
    Joined
    Jun 2014
    Location
    UNDER MY DESK
    Posts
    205
    Sub test()
         Dim FoundSrc As Range
          
         Set FoundSrc = Sheet1.Rows(1).Find("Weight(kg)")
         If Not FoundSrc Is Nothing Then
             Sheet1.Range(FoundSrc.Address).EntireColumn.Copy
             Sheet2.Paste (Cells(1, 1))
         End If
    End Sub
    - I HAVE NO IDEA WHAT I'M DOING

  6. #6
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    358
    Location
    Really thank you for you try and help , please check the attached excel file , the sheet2 is result mean when run the VBA the result must be like sheet 2

    Sample.xlsx

  7. #7
    VBAX Tutor MINCUS1308's Avatar
    Joined
    Jun 2014
    Location
    UNDER MY DESK
    Posts
    205
    EH?
    Sub TEST()
         I = 1
         Do Until Sheet1.Cells(I, 1).Value = ""
              Sheet2.Cells(I, 1).Value = Sheet1.Cells(I, 1).Value
              Sheet2.Cells(I, 2).Value = Sheet1.Cells(I, 2).Value
              Sheet2.Cells(I, 3).Value = Sheet1.Cells(I, 3).Value
              Sheet2.Cells(I, 4).Value = "Weight(kg)"
             
              J = 3
              Do Until Sheet1.Cells(I, J).Value = ""
                   If Sheet1.Cells(I, J).Value = "Weight(kg)" Then Sheet2.Cells(I, 5).Value = Sheet1.Cells(I, J + 1).Value
              J = J + 1
              Loop
         
              If Sheet2.Cells(I, 5).Value = "" Then Sheet2.Cells(I, 5).Value = "NOT FOUND"
              
         I = I + 1
         Loop
    End Sub
    - I HAVE NO IDEA WHAT I'M DOING

  8. #8
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    358
    Location
    Really appreciate for your help and working very well .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •