Consulting

Results 1 to 8 of 8

Thread: Return the value to the right of the cell

  1. #1

    Return the value to the right of the cell

    Good afternoon,
    I found it very interesting this VBA code and would like a help instead of seeking a particular cell that he seeks the word "SALE TOTAL" and return the value of the first cell right.
    Last edited by Aussiebear; 09-02-2016 at 01:32 PM. Reason: Created new thread

  2. #2
    One should not hijack someone else's thread. Start your own and refer to this thread if it is relevant.


    See if this works (I did not test it)
    Change this line
    ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1).Value = Workbooks(wb).Sheets(i).Range("B32").Value
    to this
    ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1).Value = Workbooks(wb).Sheets(i).UsedRange.Find("SALE TOTAL", , , 1).Offset(, 1).Value

  3. #3
    Jolivanes,

    Thanks, did not know this condition, the next time I will open a new thread.

  4. #4
    No problem. Did the code work for you?

  5. #5
    Jolivanes,


    Good afternoon,


    You change as you passed and is returning the message.
    Msg.JPG

  6. #6
    Can you attach a clean (no personal info) version of your workbook.
    Is your Office an English version?

  7. #7
    Good afternoon,

    Attached Files Attached Files

  8. #8
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Sub Copy_From_All_Sheets_In_All_Workbooks()
        Dim wb As String, i As Long
        Dim t
        Dim Found As Range
        Dim Dest As Range
        
        Application.ScreenUpdating = False
        t = Timer
        
        Set Dest = ThisWorkbook.Sheets("Plan1").Cells(Rows.Count, 1).End(xlUp).Offset(1)
        wb = Dir(ThisWorkbook.Path & "\*.xls*")
        Do Until wb = ""
            If wb <> ThisWorkbook.Name Then
              Workbooks.Open ThisWorkbook.Path & "\" & wb
                
                With Workbooks(wb)
                  For i = 1 To Workbooks(wb).Sheets.Count
                    Set Found = .Sheets(i).UsedRange.Find("SALE TOTAL")
                    If Not Found Is Nothing Then
                      Dest.Value = Found.Offset(, 1).Value
                      Set Dest = Dest.Offset(1)
                    End If
                  Next i
                  .Close False
                End With
            End If
            wb = Dir
        Loop
        
        Application.ScreenUpdating = True
        MsgBox "This macro took " & Format(Round(Timer - t, 2), "00:00:00.00") & " seconds to copy" & vbLf & _
        "data from all sheets in all closed workbooks."
    End Sub
    "Find().Offset" was the problem when item not found
    Last edited by SamT; 09-05-2016 at 02:39 PM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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