RefreshOnFileOpen property of a query

mlopes1

Board Regular
Joined
Jul 14, 2002
Messages
114
I have a query whose refreshOnFileOpen property is set to True. I also have some code (Merge macro) that runs on the OnOpen wkbk function that takes two of the columns brought in by the query and merges them. However, this seems to be happenning out of order.

It merges the columns, then brings in the data, thereby un-merging them again. I have tried all kinds of combinations to get the Merge macro to run after the refresh but none seem to work. Any ideas? Here is the code if that helps:

Private Sub Workbook_Open()
Merge
End Sub

Public Sub Merge()
Dim row As Integer
Dim rowcol As String
row = 25
Do While row < 126
rowcol = "C" & row & ":" & "D" & row
Range(rowcol).Select
With Selection
.MergeCells = True
End With
row = row + 1
Loop
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,221,007
Messages
6,157,350
Members
451,417
Latest member
Ilu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top