Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
JonathanK1 wrote:
I have a macro that prompts an input: Dim TheAnswer$ TheAnswer = Inputbox( Etc. etc. You get the gist. Anyway, it takes the input but doesn't do anything with it. I have one colmn in the spreadsheet that has offices (e.g., Texas, Ohio etc.). Its column H. I'd like the input to grab the rows that have the input I provide and past them into a new book/spreadsheet. Is this possible? So, there may be twenty rows with Texas mixed in. I want all of these pasted into the new spreadsheet. So when I click the button it'll ask me for the input. I enter Texas and it gives me all the rows with Texas in the new book/spreadsheet. Sorry if I'm overexplaining. Here's a 5-minute hack; see if it works for you: Sub copier() Dim TheAnswer As String Dim working As Worksheet, dumping As Workbook Set working = ActiveSheet TheAnswer = LCase$(InputBox("State?")) Set dumping = Workbooks.Add For x = 1 To working.Cells.SpecialCells(xlCellTypeLastCell).Row If LCase$(working.Cells(x, 8).Value) = TheAnswer Then working.Rows(x).EntireRow.Copy dumping.Activate ActiveSheet.Paste ActiveCell.Offset(1).Select End If Next Application.CutCopyMode = False End Sub -- This is why my characters usually end up being impossible for me to like: My curiosity leads them into actions I can't condone. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy Worksheets to New Book | Excel Programming | |||
copy worksheets to new book without linking to original book | Excel Discussion (Misc queries) | |||
VB Scrpit to input search results in Excel work book | Excel Programming | |||
Copy Worksheets from one book to another? | Excel Programming | |||
copy from one book to another | Excel Programming |