ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Spacing in Column headers (https://www.excelbanter.com/excel-worksheet-functions/449523-spacing-column-headers.html)

[email protected]

Spacing in Column headers
 
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

Claus Busch

Spacing in Column headers
 
Hi Jac,

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


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.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com