Copy multiple rows from one worksheet to another worksheet - vba

Copy multiple rows from one worksheet to another worksheet
I have a query, i have one workbook which has got around 21 columns and around 1000 rows..However i just need 4 columns
for example
let says work book A has got these columns vmware ,powerstate, dns,cpyu,memory,ssid,disk,....Here i just need vmware ,powerstate,cpu,memory and disk on workbook b.
I have tried pivot table. it just went haywire.I have a bit of vb.which i am not sure where it landed.
can any one help

You can copy rows using the following VBA Code
ThisWorkbook.Sheets("Name Of Your Source Sheet").Columns(1).Copy
ThisWorkbook.Sheets("Name Of The Destination Sheet").Columns(1).PasteSpecial xlPasteValues
Replace the 1 in Columns(1) in the first line by the number of the column you want to copy in your source sheet.
Replace the 1 in Columns(1) in the second line by the number of the column you want to paste your copied column.

Related

Copy Range of Multiple Colums and post into another worksheet within same document in VBA script

What Im trying to to is take information from row C,D,E,F,F,AL,AM from Sheet Add all the at information starts on Row 3 and put it into Sheet Final Data and start on Row 3.
Is there a way to write a VBA script for it?

VBA Copying Data from one worksheet to another but keeping data in one column intact

I need a solution to copy the data from one worksheet to another worksheet. Lets say from worksheet A to worksheet B. While copying the data the following condition has to be meet:
In worksheet B there is a column called "Comment". This Comment column should remain intact or remain the same aligning to the data even if new data is copied or while copying any data has got deleted from the worksheet A.
So basically the comments should remain even thought we copy data from worksheet A to worksheet B.
I am not into VBA and looking for an example or solution

Vba select entire colum only used range

Does anyone know how to select entire column but only used cells.
Normally the data is continuous. One issue is that sometimes the sheet is filled only for two rows sometimes for hundreds.
What I need to obtain is to loop for all the files in the folder and copy recognized columns only with data. I cannot have selection of entire column because while pasting one below previous macro will throw an error due to range area not fitting.
The source data begins in different rows. Once it starts in second row the other time in third. There are no headers.
I know this is old, but this is an easy way to select the data in a specific column and move it to a new location. It will remove all blanks in the range.
Columns("E:E").SpecialCells(xlCellTypeConstants).Copy Destination: = ActiveSheet.Range("F1")
MaxRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E1:E" & MaxRow).Select
Where E is your Column

Delete Entire Rows That Have Multiple Matching Cells

I created a macro that will copy over some information from one sheet in my workbook to another to match some criteria so I may import the info into a program. Only problem is after the macro runs, there are some blank rows and a couple duplicates. I have 12 columns of info but I would like to have the macro look at and compare entries in columns D,E,F,G and L with the row above them. So D2,E2,F2,G2 and L2 would be compared to D1,E1,F1,G1 and L1. IF all five of the entries in these cells match that of the previous row, then delete the entire row.
I've found some codes that match one cell or looks for duplicates in a certain column but nothing to look and match multiple columns and I'm so new to this that I'm having trouble even getting started.
Any and all input is welcome.
You're going to have to put in the logic of your program yourself but use something like:
worksheets("Sheet1").range("A1").offset(i, 0).resize(1, colnum).delete Shift:=xlUp
An easy way to find the commands you need is to record a macro and see what Excel uses to build that macro.

Copy all non empty cells in a sheet to another sheet in another workbook

I've got two workbooks 1. MonthlyStats and 2. WeeklyStats
I'm looking to copy all non-empty cells there are in 'Sheet1' of 'WeeklyStats' to 'SheetX' of 'MonthlyStats'. The copied data should be inserted as new rows from the last entry in 'SheetX'.
Also, is it possible that the script asks me which row to start inserting data from? That'd be great!
Thanks in advance for your help!
PS:
I'm using Excel 2010
There are no conditions on what to copy from Sheet1 of WeeklyStats. All rows with data in it should be copied over.
I personally find the best way to learn VBA is to search and try different codes in order to solve a problem. For your problem, maybe try read the post here:
Copy and Paste a set range in the next empty row
You can then use For each sheet loop to copy weekly stats from different sheets to the monthly stats sheet. Hope it helps
Regarding the question copy non blank cells, try
Worksheets("Sheet1").Activate
ActiveSheet.UsedRange.Select
Selection.copy