cancel
Showing results for 
Search instead for 
Did you mean: 

Adding the Title to the Column Header

Former Member
0 Kudos

Hi Gurus,

Using VBA I added the following code and I could see the title showing only once in the report. but when I try second time, I could not get the same result. Please help me with:

1) How to save the code? do I have to click any button after 'End Sub?

2)If I just close the editor and refresh the query, how the VBA code is activated?

3) Is the header title is going to stay for that query?

4) Pl. give the complete steps

Sub Test()

Sheets("Query").Select

Range("C28").Select

ActiveCell.FormulaR1C1 = "Product Name"

Range("A1").Select

End Sub

Accepted Solutions (1)

Accepted Solutions (1)

former_member188325
Active Contributor
0 Kudos

Hi,You have to save the Query Result as Workbook first.

Then go to visual basic editor ( Tools (from excel) > Macro>Visual basic Editor).

You will see your Excel workbook number in the lefthand side of the Window.Expand it by clicking +

it is something like VBAProject(xSAPTemp35363.xls).

under modules you will find 'SAPBEX'. paste the below Code in that module (as it is)

Sub SAPBEXonRefresh(queryID As String, resultArea As Range)

Sheets("Query").Select

Range("C28").Select

ActiveCell.FormulaR1C1 = "Product Name"

Range("A1").Select

End Sub

Save the Workbook.

Answers (1)

Answers (1)

Former Member
0 Kudos

You need to save the workbook to save the macro in it.

Former Member
0 Kudos

Pallavi,

'Save this workbook' option is greyed out.

What is SAPBExonRefresh?

Former Member
0 Kudos

You open the workbook. Add your macro & then click on save button to say "Save Existing Workbook."

Former Member
0 Kudos

why are u using VBA just to rename a column?

1) just rename it outside of the query area and then save the workbook

2) or just make a drop sheet with the new names

3) or just rename it in the query editor (structure)