Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default code help w/userform

I have had a lot of help on this project and i need just a bit more PLEASE!
I have a userform that has a listbox with multiple columns in it. I have it
set so the user can choose as many rows as they like. The data that fills the
listbox comes from a named range ("Database") from a worksheet
("ProduceData").

As the user makes their selections in the listbox(may be 1 or maybe 10
selected) and they press ENTER it needs to find all of the selections in the
database that match and places the text "Paid" in column AG. At this time the
code I have that was given to me doesn't work, it only puts one "paid" and it
doesn't ever correspond to the selections. For example if I choose invoice
numbers 1,15,26 &35 it should then find those exact numbers in the database
and put "Paid" in the same rows.

I hope i have not confused anyone. Sometimes i struggle with "what is enough
info", let me know if you need anything else. Thank you in advance. And for
those of you who have been helping me with this I promise this is the last
thing in the project that has to get done;)

Dim sh As Worksheet
Set sh = Worksheets("ProduceData")
Dim rng As Range
Set rng = sh.Range("Database").Columns(1).Cells
Dim i As Long
Dim rw As Long

For i = 0 To lstData.ListCount - 1
If lstData.Selected(i) Then
rw = rng(i + 1).Row
sh.Cells(rw, "ag").Value = "Paid"
End If
Next
--
Though daily learning, I LOVE EXCEL!
Jennifer
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default code help w/userform

Ok i see what the code is doing BUT of coarse i don't have a clue how to fix.

If i select the first row in the list box and then say the 3rd and 5th row
it is not finding the corresponding invoice number it is just placing it in
the database in row 1, 3 and 5 in the correct column but not in the correct
rows. HELP!
--
Though daily learning, I LOVE EXCEL!
Jennifer


"Jennifer" wrote:

I have had a lot of help on this project and i need just a bit more PLEASE!
I have a userform that has a listbox with multiple columns in it. I have it
set so the user can choose as many rows as they like. The data that fills the
listbox comes from a named range ("Database") from a worksheet
("ProduceData").

As the user makes their selections in the listbox(may be 1 or maybe 10
selected) and they press ENTER it needs to find all of the selections in the
database that match and places the text "Paid" in column AG. At this time the
code I have that was given to me doesn't work, it only puts one "paid" and it
doesn't ever correspond to the selections. For example if I choose invoice
numbers 1,15,26 &35 it should then find those exact numbers in the database
and put "Paid" in the same rows.

I hope i have not confused anyone. Sometimes i struggle with "what is enough
info", let me know if you need anything else. Thank you in advance. And for
those of you who have been helping me with this I promise this is the last
thing in the project that has to get done;)

Dim sh As Worksheet
Set sh = Worksheets("ProduceData")
Dim rng As Range
Set rng = sh.Range("Database").Columns(1).Cells
Dim i As Long
Dim rw As Long

For i = 0 To lstData.ListCount - 1
If lstData.Selected(i) Then
rw = rng(i + 1).Row
sh.Cells(rw, "ag").Value = "Paid"
End If
Next
--
Though daily learning, I LOVE EXCEL!
Jennifer

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default code help w/userform

If the entries in your listbox correspond to the rows of the range Database,
then it should do what you want.

If that is not case, then you would have to search the range database to
find the matching row and place it there.

Based on this new information, it sounds like the Latter, but how would
anyone know that?

You can get the code to search by turning on the macro recorder and using
Edit=Find

--
Regards,
Tom Ogilvy

"Jennifer" wrote in message
...
Ok i see what the code is doing BUT of coarse i don't have a clue how to

fix.

If i select the first row in the list box and then say the 3rd and 5th row
it is not finding the corresponding invoice number it is just placing it

in
the database in row 1, 3 and 5 in the correct column but not in the

correct
rows. HELP!
--
Though daily learning, I LOVE EXCEL!
Jennifer


"Jennifer" wrote:

I have had a lot of help on this project and i need just a bit more

PLEASE!
I have a userform that has a listbox with multiple columns in it. I have

it
set so the user can choose as many rows as they like. The data that

fills the
listbox comes from a named range ("Database") from a worksheet
("ProduceData").

As the user makes their selections in the listbox(may be 1 or maybe 10
selected) and they press ENTER it needs to find all of the selections in

the
database that match and places the text "Paid" in column AG. At this

time the
code I have that was given to me doesn't work, it only puts one "paid"

and it
doesn't ever correspond to the selections. For example if I choose

invoice
numbers 1,15,26 &35 it should then find those exact numbers in the

database
and put "Paid" in the same rows.

I hope i have not confused anyone. Sometimes i struggle with "what is

enough
info", let me know if you need anything else. Thank you in advance. And

for
those of you who have been helping me with this I promise this is the

last
thing in the project that has to get done;)

Dim sh As Worksheet
Set sh = Worksheets("ProduceData")
Dim rng As Range
Set rng = sh.Range("Database").Columns(1).Cells
Dim i As Long
Dim rw As Long

For i = 0 To lstData.ListCount - 1
If lstData.Selected(i) Then
rw = rng(i + 1).Row
sh.Cells(rw, "ag").Value = "Paid"
End If
Next
--
Though daily learning, I LOVE EXCEL!
Jennifer



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
Help with UserForm code. Richard Excel Programming 1 February 24th 06 12:23 AM
Help with UserForm Code sneagle Excel Programming 1 November 18th 05 06:41 PM
Creating a Userform using code trini Excel Programming 1 March 5th 05 11:15 PM
Userform Code scrabtree23[_3_] Excel Programming 3 December 5th 04 05:05 AM
VBA code for Userform Martin Los Excel Programming 4 December 5th 03 03:04 PM


All times are GMT +1. The time now is 06:16 AM.

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

About Us

"It's about Microsoft Excel"