LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to collect rows with user-specified cell value

I'm trying to pull a range of rows out of a sheet based on the value in

one of the columns being the same. As the value itself will change for

each time I run the macro, I need to be able to define a different
value each time - but I don't want to have to go in and amend the macro

every time.

So the macro starts with an input box where I enter the value the
routine should search for. However although vResponse is being set as
the value I enter and on the face of it the cell value and the inputted

variable match, the lines are not being pulled out and it seems it's
because Excel is not convinced they are the same. How can I correct
this?

Sub USPaymentsListExecute()

Dim vResponse As Variant
vResponse = Application.InputBox( _
Prompt:="Enter Batch Number", _
Default:=Format(Number, 0), _
Type:=2)
'If vResponse = False Then 'User cancelled

Dim myRng2 As Range
Dim myCell2 As Range
Dim HoldRng2 As Range

Set myRng2 = Range("B1:B65536")

For Each myCell2 In myRng2.Cells
If myCell2.Value = vResponse Then
If HoldRng2 Is Nothing Then
Set HoldRng2 = myCell2
Else
Set HoldRng2 = Union(myCell2, HoldRng2)
End If
End If
Next myCell2

If HoldRng2 Is Nothing Then
'do nothing
Else: HoldRng2.EntireRow.Copy
Workbooks.Add
ActiveSheet.Paste

 
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
Collect data from spesific cell in multiple sheets Espen Rostad[_2_] Excel Discussion (Misc queries) 4 March 16th 10 09:20 AM
Need Macro to Collect Multiple Worksheet Names navel151 Excel Worksheet Functions 3 February 21st 10 06:19 PM
linking multiple roles (rows) to a user (cell) Yoesrie Excel Discussion (Misc queries) 0 April 4th 07 09:38 AM
Macro to copy and paste a user selected number of rows bozwero Excel Programming 2 November 29th 06 11:32 AM
use Excel2000 as web interface to collect user input? Michael[_15_] Excel Programming 0 August 11th 05 06:25 PM


All times are GMT +1. The time now is 08:39 AM.

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"