IndentLevel

  • Thread starter Thread starter PeterW
  • Start date Start date
P

PeterW

Hello everyone

I would like to do the following:

In Column A, input a number eg " 2 " . This number represents th
IndentLevel (aka "Left (Indent)".

Upon modifying the cell in Column A, I would like the correspondin
cell of Column B of the same row to automatically reformat to th
IndentLevel indicated.

Maybe this is not possible, but thought that I would ask anyway.

Thanks in advance.
Pete
 
Paste the following to the sheet code module (not a
standard code module):

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("A")) Is Nothing Then
Target.Offset(, 1).IndentLevel = Target.Value
End If
End Sub

Regards,
Greg
 
Thanks Greg .. that works well when posted into Worksheet code!

How can I modify the code to post into the Workbook code??

Pete
 
Sorry, I don't understand your question. I don't know
what you mean by "Workbook" as opposed to "Worksheet" code.

I had intended that the code be pasted into the code
module pertaining to the worksheet involved. I'm not
clear if this is what you've done. For instance, if the
worksheet is named "Sheet1" then it should be pasted to
the code module listed in the Project Explorer window as
Sheet(Sheet1) under Microsoft Excel Objects. If you've
done this then the code should execute instantaneously
when you enter a number in Column A.

Note that I have not included error supression code. If
you enter text or a number greater than 15 in Column A
then an error message will occur. I assumed you would
look after this.

Regards,
Greg
 
To save copying the code into numerous other worksheets within the sam
workbook is it possible to do something like the following ?

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target A
Range)

If Not Intersect(Target, Columns("A")) Is Nothing Then
Target.Offset(, 1).IndentLevel = Target.Value
End If

End Sub


Regards
Pete
 
Yes. The code as you have written it works for me
(corrected for wordwrap of course) when pasted to the
ThisWorkbook code module.

Regards,
Greg
 
Back
Top