Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2020, 10:09 PM
Marcia's Avatar
Marcia Marcia is offline Code for Indent if criteria is true Windows 7 32bit Code for Indent if criteria is true Office 2013
Expert
Code for Indent if criteria is true
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default 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.
Reply With Quote
  #2  
Old 02-19-2020, 09:03 PM
Logit Logit is offline Code for Indent if criteria is true Windows 10 Code for Indent if criteria is true Office 2007
Expert
 
Join Date: Jan 2017
Posts: 529
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

.
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
Attached Files
File Type: xlsm Indent Cell Text Based On Other Cell Value.xlsm (15.3 KB, 9 views)
Reply With Quote
  #3  
Old 02-20-2020, 05:41 AM
Marcia's Avatar
Marcia Marcia is offline Code for Indent if criteria is true Windows 7 32bit Code for Indent if criteria is true Office 2013
Expert
Code for Indent if criteria is true
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default

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?
Reply With Quote
  #4  
Old 02-20-2020, 08:14 AM
Logit Logit is offline Code for Indent if criteria is true Windows 10 Code for Indent if criteria is true Office 2007
Expert
 
Join Date: Jan 2017
Posts: 529
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

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
Reply With Quote
  #5  
Old 02-20-2020, 05:54 PM
Marcia's Avatar
Marcia Marcia is offline Code for Indent if criteria is true Windows 7 32bit Code for Indent if criteria is true Office 2013
Expert
Code for Indent if criteria is true
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default

Perfect. Thank you again Logit. We, users are amazed.
Reply With Quote
  #6  
Old 02-20-2020, 06:28 PM
Logit Logit is offline Code for Indent if criteria is true Windows 10 Code for Indent if criteria is true Office 2007
Expert
 
Join Date: Jan 2017
Posts: 529
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

You are welcome.
Reply With Quote
Reply

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
Code for Indent if criteria is true How to modify code for Auto filter based on two criteria ... LearnerExcel Excel Programming 13 02-14-2018 08:20 PM
Code for Indent if criteria is true Issue of 2 fixed bullet points indent setting work together (code included) puff Word VBA 5 12-17-2017 05:52 PM
Code for Indent if criteria is true 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft