VB Code to insert column headers

jose001

Board Regular
Joined
Mar 27, 2006
Messages
103
Morning everyone,

I've been struggling with a little job I started yesterday and its slowly driving me mad! I have a pretty simple form which feeds some info into excel. Does anyone have any idea what code I would need to get it to insert specific headers into the sheet?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Can you perhaps give an example of the form and code you have alreaddy, where the headers are coming from and where you want them to go?
 
Upvote 0
Hi Lewiy,

After a lot of messing around I've finally sorted this, allbeit in a very drawnout way. Nevertheless, I am now left with one final hurdle, with your help my form now generates sheets and gives them the title obtained from one of the input fields. I would now like to add a summary sheet which will go into every sheet and oull out the information from two of the cells and put it on the summary. I could do it easily if I knew the name of every sheet but they are generated buy everyone in the team. Any ideas?
 
Upvote 0
You can use this method to cycle through all of the sheets in the workbook (except one named "Summary")
Code:
Dim wb As Workbook
Dim sh As Worksheet
Set wb = ThisWorkbook
For Each sh In wb.Workbooks
    If sh.Name <> "Summary" Then
        'do stuff here
        '"sh" will refer to the current worksheet in the loop
        'e.g:
        'sh.Range("A1").Value
        'will return the value of cell A1 in each of the sheets in
        'the workbook one at a time
    End If
Next sh
 
Upvote 0
Thanks for this code lewiy! Sadly I can't manipulate it to get it to work. I'm trying to get the code to go through all of the sheets and pull out the info from cell A2 and pop it in cell B6 of my summary sheet and then cell A3 and pop that into C6. The thing is, because there are many sheets I will need this process to repeat filling each row from B6 down with the information from the other sheets. Help!! :)
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

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