Copy some specific columns whose header is merge

guptasweb

New Member
Joined
Jun 17, 2024
Messages
21
Office Version
  1. 2019
Platform
  1. Windows
I have one excel file in which header is merged and I want ABC2024 data.under this header 12 columns are there i.e Jan,Feb,MAr,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec and one column before the ABC2024.is it possible?
 
yes,I dont want data from D-V and the the next thing is I want data of Column -C, W-AV.I want to Place the data in a new sheet and the sheet name would be 2024Data
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Please answer the questions I asked in post #7!
Remember, while you are familiar with your issue and known exactly what you want to do, we are not. We are reliant on you to fully and clearly communicate exactly what it is that you are trying to accomplish.

Also, are you trying to do this "in place", or on a new sheet?
If on a new sheet, it appears that maybe you just need copy columns B-D and W-AH. Is that correct?
Are the values in those columns in the original sheet hard-coded values, formulas, or a mixture of the two?
And if copying to a new sheet, does this sheet already exist, or does it need to be created?
What are the names of the sheets?

Please answer ALL these questions!
yes,I dont want from B,D-V and from AV till the end of the sheet
 
Upvote 0
All you really need to do is the following:
1. Insert a new sheet
2. Copy all the data from the original sheet to the new sheet
3. Delete the columns you don't want on the new sheet

You could actually get most of the VBA code you need simply by turning on the Macro Recorder and recording yourself performing those steps manually.

Your descriptions on which columns to keep/delete do not seem to match up exactly with your images. However, I have documented the code below so that you should easily be able to edit it to suit your needs.
VBA Code:
Sub MyCopy()

    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    
'   Capture current worksheet
    Set ws1 = ActiveSheet
    
'   Insert new worksheet and rename it
    Sheets.Add After:=ActiveSheet
    ActiveSheet.Name = "2024Data"
    Set ws2 = ActiveSheet

'   Copy columns A-AT
    ws1.Activate
    Columns("A:AT").Copy
    ws2.Activate
    Range("B1").Select
    ActiveSheet.Paste
    
'   Delete columns you don't want
    Columns("E:V").Delete

End Sub
 
Upvote 0
All you really need to do is the following:
1. Insert a new sheet
2. Copy all the data from the original sheet to the new sheet
3. Delete the columns you don't want on the new sheet

You could actually get most of the VBA code you need simply by turning on the Macro Recorder and recording yourself performing those steps manually.

Your descriptions on which columns to keep/delete do not seem to match up exactly with your images. However, I have documented the code below so that you should easily be able to edit it to suit your needs.
VBA Code:
Sub MyCopy()

    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
   
'   Capture current worksheet
    Set ws1 = ActiveSheet
   
'   Insert new worksheet and rename it
    Sheets.Add After:=ActiveSheet
    ActiveSheet.Name = "2024Data"
    Set ws2 = ActiveSheet

'   Copy columns A-AT
    ws1.Activate
    Columns("A:AT").Copy
    ws2.Activate
    Range("B1").Select
    ActiveSheet.Paste
   
'   Delete columns you don't want
    Columns("E:V").Delete

End Sub
i tried it but when I paste the data in vba activity it shows error
 
Upvote 0
Upvote 0
yes actually I am using RPA tool in which I need to do some macro before working on it.So in order to run macro I need to use VBA in RPA
You should have mentioned that at the very beginning!
I have never used RPA, so I cannot offer any advice on using that.
 
Upvote 0
You should have mentioned that at the very beginning!
I have never used RPA, so I cannot offer any advice on using that.
thanks it worked.Could you pls help me to remove empty rows because earlier I am using a long code
 
Upvote 0
thanks it worked.Could you pls help me to remove empty rows because earlier I am using a long code
Do you mean the empty rows in between each Process Type?
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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