LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Gord Dibben
 
Posts: n/a
Default

Beth

Indenting is a crap-shoot at best what with different fonts and resolutions.

Use this macro to indent 5 spaces(not characters). No error-check and if cell
already contains leading spaces, will add to them. Works on both numbers and
text but not cells with formulas.

Sub Format_Indent5()
Dim cell As Range, I As Integer, tempS As String
For Each cell In Intersect(Selection, ActiveSheet.UsedRange)
If Not cell.HasFormula Then
If cell.PrefixCharacter = "'" Then
cell.NumberFormat = " @"

ElseIf IsNumeric(cell.Value) Then
cell.NumberFormat = " " & cell.NumberFormat

Else
cell.NumberFormat = " @"
End If
End If
Next
End Sub


The following allows you to choose number of spaces and indenting left or
right.

Sub Indent_Text()
Dim num As Integer, str As String
Dim cell As Range, I As Integer

num = Application.InputBox(prompt:="Enter the number of " & _
"spaces to indent text. If a negative number " & _
"is entered, text will be shifted left that ." & _
"number Truncation may occur. Only text " & _
"entries are affected.", _
Type:=1)
If num = 0 Then
MsgBox "No value entered. Activity halted."
End
End If
If num 0 Then
For I = 1 To num
str = str & " "
Next
For Each cell In Intersect(Selection, _
ActiveSheet.UsedRange)
If (Not IsEmpty(cell)) And (Not IsNumeric(cell)) And _
(Not Left(cell.Formula, 1) = "=") Then
cell.Value = str & cell.Value
End If
Next cell
Else
For Each cell In Intersect(Selection, _
ActiveSheet.UsedRange)
If (Not IsEmpty(cell)) And (Not IsNumeric(cell)) And _
(Not Left(cell.Formula, 1) = "=") Then
If Len(cell.Value) + num 0 Then
cell.Value = Right(cell.Value, _
Len(cell.Value) + num)
Else
cell.ClearContents
End If
End If
Next cell
End If
End Sub


Gord Dibben Excel MVP With thanks to Bob Flanagan for the code.

On Thu, 3 Mar 2005 07:27:01 -0800, "Beth" <Beth @discussions.microsoft.com
wrote:

We work with standards that have been set for the company. One is that when
creating tables, the indentation of sub-categories of a table must be 5
spaces. The indent option (under Format/Alignment), when set to five, seems
to actually indent 15 spaces. I'm looking for a way to create a template that
we can use as a basis for all tables, is there a way to set the indent option
so that using it actually indents five spaces (as in five space bar spaces)?
Thanks in advance.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I merge cells in Excel, like just 2 cells to make one big . chattacat Excel Discussion (Misc queries) 2 January 19th 05 04:25 PM
Formatting cells in Excel for certain Values to appear certain Col Lucius Excel Worksheet Functions 2 December 24th 04 10:47 AM
Excel Charts and cells sacha Charts and Charting in Excel 1 November 30th 04 02:30 PM
How do I password protect cells in a spreadsheet created in Excel [email protected] Excel Worksheet Functions 0 November 22nd 04 09:21 PM
How do I "Wrap Text" & "Autofit" within Merged Cells in Excel? 6-shooter Excel Worksheet Functions 3 October 31st 04 12:14 AM


All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"