Selecting a Column using Numeric Row/Column Values

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
Hi,

I am having an issue with providing the correct syntax to select a column in my source worksheet and then copy and paste this column into my target worksheet.

My Workbook (executing the code) we'll call MainBook. The Source Workbook is SourceBook (XferArray(1)). The Source Sheet is SourceSheet (XferArray(3)). The Target sheet is Tmp Tab.

My Code is:

Code:
    Windows(XferArray(1)).Activate
    For i = 0 To UBound(OrgTrgColH)
        'XferArray(1) = Workbook Name
        'XferArray(3) = Sheet Name
        'OrgTrgColH(x,0) = Original Column Number XferArray(3) sheet
        'OrgTrgColH(x,2) = New Column Number in Tmp Tab sheet

        Workbooks(XferArray(1)).Sheets(XferArray(3)).Activate
        [PHP]Columns(Int(OrgTrgColH(i, 0)), Int(OrgTrgColH(i, 0))).Select[/PHP]
        
        Selection.Copy
        
        Workbooks(XferArray(1)).Sheets("Tmp Tab").Activate
        Columns(OrgTrgColH(i, 2), OrgTrgColH(i, 2)).Select
        ActiveSheet.Paste
        
        Windows(ThisWorkbook.Name).Activate
        
    Next i

Any help would greatly be appreciated.

Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
The statement must equate to the format of Columns(26) or Columns("Z").
Neither Columns(26, 26) Nor Columns("z", "z") Nor Columns("z, Z") Nor Columns("z:z") will work.
You could try:
Code:
 Columns(OrgTrgColH(i, 2)).Select
If OrgTrgColH(i, 2) equates to an integer value, then it should work.
 
Upvote 0
Thank you JLGWhiz. That worked perfectly. I wish I can get a better handle on selections and ranges. These seem to confuse me the most. With time/experience, perhaps.
 
Upvote 0
I wouldn't worry too much about it, we all stumble and grope periodically. I use the help files frequently and keep old proceures that I had to spend a lot of time debugging for refences. No way I can remember all the variations of stuff in this code. Thanks for the feedback.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top