Help Please Cutting and pasting based on cell value
Help please, I am trying to automate the cutting and pasting of lines
based on a value of a cell. I have a spreadsheet that is partly automated that sorts contact data and will copy a selected range into a new spreadsheet. What I want to try to do is select rows within this that have a status = good and paste them only to my template spreadsheet. I have worked out how to automate the file saving with a date and timestamp but not how to make the selection and invoke a message box to confirm the the selection. Layout is : Date/Name/Company/Address/Product/Status/Ship/Product/Qty/ +5 columns with Sales Data My template just needs the first nine columns for an import process and the rest are disregarded. Any help at all would be grately appreciated Many thanks Mike |
Help Please Cutting and pasting based on cell value
So you want the code to go down some column and when it sees the word
"good" to cut that row, and paste it onto the template sheet? If so, what column are goods in? |
Help Please Cutting and pasting based on cell value
|
Help Please Cutting and pasting based on cell value
Try the following:
Sub templatecopier() mainsheet = ActiveSheet.Name Dim intcounter As Integer Dim lastrow As Integer lastrow = ActiveSheet.UsedRange.Rows.Count intcounter = 2 Cells(intcounter, 6).Select Do Until intcounter = lastrow + 1 If ActiveCell.Value = "good" Then ActiveCell.EntireRow.Copy Sheets("Template").Select Range("A1").Select Selection.Insert Shift:=xlDown Sheets(mainsheet).Select End If intcounter = intcounter + 1 Cells(intcounter, 6).Select Loop Application.CutCopyMode = False Range("A1").Select End Sub |
All times are GMT +1. The time now is 10:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com