Jump to content
xcaliber13

Excel column shift help

Recommended Posts

Just a quick question about excel and shifting columns.   I use this code  works great:

For $a = 1 To $aLastRow
    $aCell = _Excel_RangeRead($oWorkbook, Default, "Q" & $a)
    If $aCell = "S"  Then _Excel_RangeInsert($oWorkBook.Activesheet, "Q" & $a, $xlShiftToRight)
Next

But this only shift to the right one(1) column.   Now my question:

Is there a way to code this to shift to the right X amount of columns?   So instead of just shifting over one(1) column is there a way to make it shift over lets say 3 columns?

thank you

Share this post


Link to post
Share on other sites

Check example 2 in the help file for how to insert > 1 column.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version 1.3.5.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-01-22 - Version 0.1.0.0) - Download - General Help & Support
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

water,

        Thank you for the reply.   I tried what the example 2 showed to do but nothing gets moved.  Here is what I tried.

For $a = 1 To $aLastRow
    $aCell = _Excel_RangeRead($oWorkbook, Default, "Q" & $a)
    If $aCell = "S"  Then _Excel_RangeInsert($oWorkBook.Activesheet, "Q:T" & $a, $xlShiftToRight)
Next

I am I not understanding the example correctly?

Share this post


Link to post
Share on other sites

I think it should be:

"Q" & $a & ":T" & $a

So on row 3 you would insert Q3:T3


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version 1.3.5.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-01-22 - Version 0.1.0.0) - Download - General Help & Support
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version 1.3.5.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-01-22 - Version 0.1.0.0) - Download - General Help & Support
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...