Consulting

Results 1 to 8 of 8

Thread: finding the value and paste in another sheet .

  1. #1

    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
      To view attachments your post count must be 0 or greater. Your post count is 0 momentarily.
    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,137
    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) 
    
    
    Formatting tags added by mark007
    You might have to edit the Find Parameters.
    Please take the time to read the Forum FAQ

  3. #3
    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,137
    Location
    Research the offered code and adjust as needed.
    Please take the time to read the Forum FAQ

  5. #5
    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 
    
    
    Formatting tags added by mark007
    -I HAVE NO IDEA WHAT I'M DOING

  6. #6
    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
    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 
    
    
    Formatting tags added by mark007
    -I HAVE NO IDEA WHAT I'M DOING

  8. #8
    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
  •