Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use comma separated inputs in macro

Hello

I have strange requirement.
I have a column with hundreds of entries in it. There is one other columns
associated eith it. For an example consider that following are the entries in
column A and B

Column A Column B

PI03590 bar
ZT05693 %
PIC098734 N
TT09823 C

Now I have to provide one userform input box to user. The user will enter
entries separated by comma (or any other character). I have to filter entres
in column B as per these inputs.
e.g. If user enters (bar, N) in the input box, then macro should filter
entries in column B and copy "unmatched" result to new sheet. In this case,
Macro should copy following information in new sheet:


ZT05693 %
TT09823 C.

(I do not want the user to manually filter it in the sheet as this needs to
be incorporated in the already existing macro which performs several actions
on the sheet.)

Thank You in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to use comma separated inputs in macro

I think this macro will do what you want, just assign the appropriate sheet
names to the two Const (constant) statements (and rename the macro to
something more appropriate)...

Sub CopyNonSpecifiedColumnBItemRows()
Dim UserInput As String, UserList() As String, Cell As Range
Dim SourceLastRow As Long, DestinationLastRow As Long
Const Source As String = "Sheet4"
Const Destination As String = "NewSheet"
SourceLastRow = Worksheets(Source).Cells(Rows.Count, "B").End(xlUp).Row
DestinationLastRow = Worksheets(Destination).Cells( _
Rows.Count, "B").End(xlUp).Row
UserInput = InputBox("List items separated by commas", "Get User List")
If Len(UserInput) Then
UserInput = "," & Replace(UserInput, " ", "") & ","
For Each Cell In Worksheets(Source).Range("B1:B" & SourceLastRow)
If InStr(1, UserInput, "," & Cell.Value & ",", vbTextCompare) = 0 Then
Cell.EntireRow.Copy
Worksheets(Destination).Cells(DestinationLastRow, "A")
DestinationLastRow = DestinationLastRow + 1
End If
Next
End If
End Sub

--
Rick (MVP - Excel)


"Pawan" wrote in message
...
Hello

I have strange requirement.
I have a column with hundreds of entries in it. There is one other columns
associated eith it. For an example consider that following are the entries
in
column A and B

Column A Column B

PI03590 bar
ZT05693 %
PIC098734 N
TT09823 C

Now I have to provide one userform input box to user. The user will enter
entries separated by comma (or any other character). I have to filter
entres
in column B as per these inputs.
e.g. If user enters (bar, N) in the input box, then macro should filter
entries in column B and copy "unmatched" result to new sheet. In this
case,
Macro should copy following information in new sheet:


ZT05693 %
TT09823 C.

(I do not want the user to manually filter it in the sheet as this needs
to
be incorporated in the already existing macro which performs several
actions
on the sheet.)

Thank You in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use comma separated inputs in macro

Thanks Rick.

However I am getting error at the line

Worksheets(Destination).Cells(DestinationLastRow, "A")



"Rick Rothstein" wrote:

I think this macro will do what you want, just assign the appropriate sheet
names to the two Const (constant) statements (and rename the macro to
something more appropriate)...

Sub CopyNonSpecifiedColumnBItemRows()
Dim UserInput As String, UserList() As String, Cell As Range
Dim SourceLastRow As Long, DestinationLastRow As Long
Const Source As String = "Sheet4"
Const Destination As String = "NewSheet"
SourceLastRow = Worksheets(Source).Cells(Rows.Count, "B").End(xlUp).Row
DestinationLastRow = Worksheets(Destination).Cells( _
Rows.Count, "B").End(xlUp).Row
UserInput = InputBox("List items separated by commas", "Get User List")
If Len(UserInput) Then
UserInput = "," & Replace(UserInput, " ", "") & ","
For Each Cell In Worksheets(Source).Range("B1:B" & SourceLastRow)
If InStr(1, UserInput, "," & Cell.Value & ",", vbTextCompare) = 0 Then
Cell.EntireRow.Copy
Worksheets(Destination).Cells(DestinationLastRow, "A")
DestinationLastRow = DestinationLastRow + 1
End If
Next
End If
End Sub

--
Rick (MVP - Excel)


"Pawan" wrote in message
...
Hello

I have strange requirement.
I have a column with hundreds of entries in it. There is one other columns
associated eith it. For an example consider that following are the entries
in
column A and B

Column A Column B

PI03590 bar
ZT05693 %
PIC098734 N
TT09823 C

Now I have to provide one userform input box to user. The user will enter
entries separated by comma (or any other character). I have to filter
entres
in column B as per these inputs.
e.g. If user enters (bar, N) in the input box, then macro should filter
entries in column B and copy "unmatched" result to new sheet. In this
case,
Macro should copy following information in new sheet:


ZT05693 %
TT09823 C.

(I do not want the user to manually filter it in the sheet as this needs
to
be incorporated in the already existing macro which performs several
actions
on the sheet.)

Thank You in advance


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to use comma separated inputs in macro

It looks like the newsreader word-wrapped that line from the line above it.
What you are seeing as this...

Cell.EntireRow.Copy
Worksheets(Destination).Cells(DestinationLastRow, "A")

should all be on one line with a space character between them, like this...

Cell.EntireRow.Copy Worksheets(Destination).Cells(DestinationLastRow, "A")

--
Rick (MVP - Excel)


"Pawan" wrote in message
...
Thanks Rick.

However I am getting error at the line

Worksheets(Destination).Cells(DestinationLastRow, "A")



"Rick Rothstein" wrote:

I think this macro will do what you want, just assign the appropriate
sheet
names to the two Const (constant) statements (and rename the macro to
something more appropriate)...

Sub CopyNonSpecifiedColumnBItemRows()
Dim UserInput As String, UserList() As String, Cell As Range
Dim SourceLastRow As Long, DestinationLastRow As Long
Const Source As String = "Sheet4"
Const Destination As String = "NewSheet"
SourceLastRow = Worksheets(Source).Cells(Rows.Count, "B").End(xlUp).Row
DestinationLastRow = Worksheets(Destination).Cells( _
Rows.Count, "B").End(xlUp).Row
UserInput = InputBox("List items separated by commas", "Get User List")
If Len(UserInput) Then
UserInput = "," & Replace(UserInput, " ", "") & ","
For Each Cell In Worksheets(Source).Range("B1:B" & SourceLastRow)
If InStr(1, UserInput, "," & Cell.Value & ",", vbTextCompare) = 0
Then
Cell.EntireRow.Copy
Worksheets(Destination).Cells(DestinationLastRow, "A")
DestinationLastRow = DestinationLastRow + 1
End If
Next
End If
End Sub

--
Rick (MVP - Excel)


"Pawan" wrote in message
...
Hello

I have strange requirement.
I have a column with hundreds of entries in it. There is one other
columns
associated eith it. For an example consider that following are the
entries
in
column A and B

Column A Column B

PI03590 bar
ZT05693 %
PIC098734 N
TT09823 C

Now I have to provide one userform input box to user. The user will
enter
entries separated by comma (or any other character). I have to filter
entres
in column B as per these inputs.
e.g. If user enters (bar, N) in the input box, then macro should filter
entries in column B and copy "unmatched" result to new sheet. In this
case,
Macro should copy following information in new sheet:


ZT05693 %
TT09823 C.

(I do not want the user to manually filter it in the sheet as this
needs
to
be incorporated in the already existing macro which performs several
actions
on the sheet.)

Thank You in advance


.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default How to use comma separated inputs in macro

Thanks Rick. Its perfect. :)

"Rick Rothstein" wrote:

It looks like the newsreader word-wrapped that line from the line above it.
What you are seeing as this...

Cell.EntireRow.Copy
Worksheets(Destination).Cells(DestinationLastRow, "A")

should all be on one line with a space character between them, like this...

Cell.EntireRow.Copy Worksheets(Destination).Cells(DestinationLastRow, "A")

--
Rick (MVP - Excel)


"Pawan" wrote in message
...
Thanks Rick.

However I am getting error at the line

Worksheets(Destination).Cells(DestinationLastRow, "A")



"Rick Rothstein" wrote:

I think this macro will do what you want, just assign the appropriate
sheet
names to the two Const (constant) statements (and rename the macro to
something more appropriate)...

Sub CopyNonSpecifiedColumnBItemRows()
Dim UserInput As String, UserList() As String, Cell As Range
Dim SourceLastRow As Long, DestinationLastRow As Long
Const Source As String = "Sheet4"
Const Destination As String = "NewSheet"
SourceLastRow = Worksheets(Source).Cells(Rows.Count, "B").End(xlUp).Row
DestinationLastRow = Worksheets(Destination).Cells( _
Rows.Count, "B").End(xlUp).Row
UserInput = InputBox("List items separated by commas", "Get User List")
If Len(UserInput) Then
UserInput = "," & Replace(UserInput, " ", "") & ","
For Each Cell In Worksheets(Source).Range("B1:B" & SourceLastRow)
If InStr(1, UserInput, "," & Cell.Value & ",", vbTextCompare) = 0
Then
Cell.EntireRow.Copy
Worksheets(Destination).Cells(DestinationLastRow, "A")
DestinationLastRow = DestinationLastRow + 1
End If
Next
End If
End Sub

--
Rick (MVP - Excel)


"Pawan" wrote in message
...
Hello

I have strange requirement.
I have a column with hundreds of entries in it. There is one other
columns
associated eith it. For an example consider that following are the
entries
in
column A and B

Column A Column B

PI03590 bar
ZT05693 %
PIC098734 N
TT09823 C

Now I have to provide one userform input box to user. The user will
enter
entries separated by comma (or any other character). I have to filter
entres
in column B as per these inputs.
e.g. If user enters (bar, N) in the input box, then macro should filter
entries in column B and copy "unmatched" result to new sheet. In this
case,
Macro should copy following information in new sheet:


ZT05693 %
TT09823 C.

(I do not want the user to manually filter it in the sheet as this
needs
to
be incorporated in the already existing macro which performs several
actions
on the sheet.)

Thank You in advance


.


.



Reply
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
text string separated by comma Atishoo Excel Discussion (Misc queries) 6 February 12th 09 05:19 PM
How can I extract the first & last name separated by a comma MSA Excel Discussion (Misc queries) 5 September 18th 06 03:28 PM
Fixing Comma Separated Values (.csv) dickives Excel Discussion (Misc queries) 1 February 14th 06 03:26 PM
Going from column to comma separated list... jmboggiano Excel Discussion (Misc queries) 1 March 10th 05 04:30 PM
CSV (Comma Separated Values) delimiter ? Lisa Pearlson Excel Programming 6 January 6th 04 02:30 PM


All times are GMT +1. The time now is 06: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"