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 from B,D-V and from AV till the end of the sheetPlease 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!
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 errorAll 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 am not sure what you mean when you say "I paste the data in vba activity".i tried it but when I paste the data in vba activity it shows error
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 RPAI am not sure what you mean when you say "I paste the data in vba activity".
You should be posting this code in a new VBA module, and then running it.
See here for how to do that: Insert and run VBA macros in Excel - step-by-step guide.
You should have mentioned that at the very beginning!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
thanks it worked.Could you pls help me to remove empty rows because earlier I am using a long codeYou should have mentioned that at the very beginning!
I have never used RPA, so I cannot offer any advice on using that.