Macro problem within Visual Basic

mitch.bergmans

New Member
Joined
Feb 11, 2005
Messages
9
Hi all,

What I want to do is select a couple of columns out of 150 columns and paste them on the next sheet trhough a macro. This is quite easy, but the problem is: The columns I want to copy are never in the same position.

For Example: The first Column I want to copy is : RECORD ID. Sometimes its in column AN but next month it could be column AE. So to avoid that I use the CTRL+f function within my macro. And then my problem starts. After de search the cursor is op top of the right coluwn. I want to copy that column without saying what column it exactly is. Below I´ll show you my Marco for now:


Code:
    Sheets("output").Select
    Range("A1").Select

    Cells.Find(What:="RECORD ID", After:=ActiveCell, LookIn:=xlFormulas,
    LookAt _:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
    MatchCase:= _False, SearchFormat:=False).Activate

    Columns("AN:AN").Select
    Selection.Copy
    Sheets("sheet2").Select
    Range("A1").Select
    ActiveSheet.Paste
The problem is: Columns("AN:AN").Select. There should be a formula which says: Select entirecolumn. without registrating it´s concerning column AN.

Can some1 help me PLZ?

Mitch
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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