Spacing in Column headers

J

jacquie.levett

Hi

I was wondering if anyone can give me a magic fix!

My company have developed a a system to track our current pursuits, my role is to export this data into Excel.

When the data pulls through, the 30+ column headers have no spacing, is there a quick way to fix this other than manually inputting the spaces?

Example below:

ProjectReference LeadProjectReference ProjectTitle


Thanks
Jac
 
C

Claus Busch

Hi Jac,

Am Wed, 20 Nov 2013 02:31:49 -0800 (PST) schrieb
(e-mail address removed):

When the data pulls through, the 30+ column headers have no spacing, is there a quick way to fix this other than manually inputting the spaces?
ProjectReference LeadProjectReference ProjectTitle

try following code (modify the range to suit):

Sub Headers()
Dim rngC As Range
Dim i As Integer
Dim j As Integer
Dim n As Integer

For Each rngC In Range("A1:C1")
For i = 2 To Len(rngC)
For j = 65 To 90
n = InStr(i, rngC, Chr(j))
If n > 0 Then
If Mid(rngC, n - 1, 1) <> " " Then
rngC = Replace(rngC, Chr(j), " " & Chr(j))
i = n + 1
End If
End If
Next
Next
Next
End Sub


Regards
Claus B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top