#1
|
||||
|
||||
Code for Indent if criteria is true
Hi. Here is another SOS call. Would somebody please provide a code for the ff: If E4:E15>0, the text in B4:B15 should be indented by .25" This applies to specific worksheets not workbook. I am doing the indentation manually but I am sure a VBA could coolly perform the task. I am a candidate for vba disabled so as much as I would like to start something that the vba gurus would correct, I couldn't. Thank you. |
#2
|
|||
|
|||
.
This macro will do what you are seeking : Code:
Option Explicit Sub IndentB() Dim i As Range For Each i In Sheets("Sheet1").Range("E4:E15") If i.Value > 0 Then i.Offset(0, -3).InsertIndent 2 ' Offset selection from column E End If Next i End Sub |
#3
|
||||
|
||||
Thank you Logit. I've just finished pasting the macro to the actual sheets, making minor edits due to the presence of merged columns. It took me more than 2 hours😊😊.
One more thing please. Could you add a macro that resets the data in Col B on the left, I guess that is another button, before clicking the indent button? |
#4
|
|||
|
|||
Code:
Sub IndentB() Dim i As Range For Each i In Sheets("Sheet1").Range("E4:E15") If i.Value > 0 Then i.Offset(0, -3).InsertIndent -2 ' Offset selection from column E End If Next i End Sub |
#5
|
||||
|
||||
Perfect. Thank you again Logit. We, users are amazed.
|
#6
|
|||
|
|||
You are welcome.
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Difference between first line Indent and Left Indent | kingston123 | Word | 3 | 09-25-2018 02:47 PM |
How to modify code for Auto filter based on two criteria ... | LearnerExcel | Excel Programming | 13 | 02-14-2018 08:20 PM |
Issue of 2 fixed bullet points indent setting work together (code included) | puff | Word VBA | 5 | 12-17-2017 05:52 PM |
Create a unique list of values that match a criteria, sorted in order of another criteria | BradRichardson | Excel | 2 | 01-03-2017 12:25 AM |
Find criteria, then paste- code is overwriting data | ufopilot | Excel Programming | 0 | 02-18-2016 10:14 PM |