xcaliber13

Excel column shift help

6 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

#4 ·  Posted

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 (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

Water,

          Once again you are correct.   That is what works.

Thank you

Share this post


Link to post
Share on other sites

#6 ·  Posted

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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