How To Refresh All

Hi,
I have one Excel file Insert some data. After i want to Refresh All pls any one guide me
Regards

You can use below activity!
image

1 Like

hi @MD_Farhan1

you can refer the below thread

1 Like

Hi @MD_Farhan1

Sub RefreshAllConnections()
    Dim con As WorkbookConnection
    
    ' Loop through all connections in the workbook
    For Each con In ThisWorkbook.Connections
        ' Refresh each connection
        con.Refresh
    Next con
End Sub

Hope it helps!!

1 Like

Hi @MD_Farhan1

Can you try the below

Refresh Excel.txt (56 Bytes)

Cheers!!

1 Like

i have Many sheets in same excel connect with Data sheet . i want refresh all sheets.

Hi @MD_Farhan1

You can use the below Macors code to refresh the workbook

Sub RefreshAllData()
    ThisWorkbook.RefreshAll
End Sub

RefreshAllData.txt (60 Bytes)

Regards

1 Like

@MD_Farhan1

Try this it will refresh all sheets

1 Like

Hi @MD_Farhan1

This will refresh all the sheets.

Regards

1 Like


i got this error

You have to enable this in Excel to run the macro

1 Like

@MD_Farhan1

Enable macros in your excel

1 Like

how to do pls step by step instruct me?

Hi @MD_Farhan1

Please enable the macro settings for you excel.

Once you go to the below mentioned view by clicking the file option in excel then you please follow the steps:

After going to macros please enable all those settings and then please run the code

Regards

1 Like

@MD_Farhan1

Please go through this

1 Like

i want another one clarification. how to set text align center only string column not number column

Hi @MD_Farhan1

Use the below Invoke VBA code:

Sub RefreshAndFormat()
    ' Refresh all data
    ThisWorkbook.RefreshAll

    ' Set text alignment to center for string columns
    Dim ws As Worksheet
    Dim col As Range
    Dim cell As Range

    ' Assuming data starts in column A and ends in column Z (adjust as needed)
    For Each ws In ThisWorkbook.Sheets
        For Each col In ws.UsedRange.Columns
            For Each cell In col.Cells
                If Not IsNumeric(cell.Value) Then
                    cell.HorizontalAlignment = xlCenter
                End If
            Next cell
        Next col
    Next ws
End Sub

This will refresh all your sheets and string column will be aligned at the center.

ExportToPDF.txt (607 Bytes)

Happy Automation
Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.