• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA meaning for the below macro

seanteo

New Member
Can anyone explain what is the below code ' clientname = Sheets("Client_S").Cells(4 + Range("Clientname"), 1).Value ' mean ? What does the 4 and 1 doing ?

Code:
Sub SelectClientName()
    On Error GoTo Err
    Dim p As PivotTable
    Dim sht As Worksheet
    For Each sht In ThisWorkbook.Sheets
        For Each p In sht.PivotTables
            Select Case sht.Name
            Case "Client_S"
            Case Else
                If Range("Clientname") = "" Then
                    p.PivotFields("Client").CurrentPage = _
                    "(All)"
                Else
                  
                    clientname = Sheets("Client_S").Cells(4 + Range("Clientname"), 1).Value
                                      
                    a = sht.Name
                    p.PivotFields("Client").CurrentPage = _
                    clientname

                End If
                p.RefreshTable
              
            End Select
        Next
    Next
  
    MsgBox "Pivot Updated !!!", vbInformation, "Completed"
  
    Exit Sub
Err:
    MsgBox "Client name not found"
  
End Sub
 
Back
Top