LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Input, copy, new book?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Worksheets to New Book Nigel Excel Programming 1 October 21st 09 09:52 AM
copy worksheets to new book without linking to original book Lori Excel Discussion (Misc queries) 2 March 4th 09 04:46 PM
VB Scrpit to input search results in Excel work book Code Numpty Excel Programming 0 March 7th 08 04:14 PM
Copy Worksheets from one book to another? Jonx[_4_] Excel Programming 5 August 17th 04 10:55 AM
copy from one book to another portroe Excel Programming 2 January 27th 04 09:17 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"