|
-
Oct 5th, 2009, 05:29 AM
#41
Re: Code Dont work
What is the error message that you get?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 5th, 2009, 06:53 AM
#42
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 5th, 2009, 08:15 AM
#43
Thread Starter
Hyperactive Member
Re: Code Dont work
ok a few problems now, just realised the additem does work but it adds entries to my comboboxes causing duplicates, all i want it do is display what exists and not add anything to the comboboxes.
alo my search function is there anyway i can get it to descend search? from bottom to top not top to bottom?
Code:
Private Sub Search()
Set r = Sheets("Database").UsedRange.Find(TextBox3.Value)
If Not r Is Nothing Then
TextBox1 = r.Offset(0, -2)
TextBox2 = r.Offset(0, -1)
TextBox3 = r.Offset(0)
TextBox4 = r.Offset(0, 1)
TextBox5 = r.Offset(0, 2)
TextBox6 = r.Offset(0, 3)
ComboBox1.AddItem r.Offset(0, 4)
ComboBox2.AddItem r.Offset(0, 5)
ComboBox3.AddItem r.Offset(0, 6)
Worksheets("ES19").Range("i7").Value = TextBox1.Value
Worksheets("ES19").Range("i9").Value = TextBox2.Value
Worksheets("ES19").Range("z7").Value = TextBox3.Value
Worksheets("ES19").Range("z11").Value = TextBox4.Value
Worksheets("ES19W").Range("i7").Value = TextBox1.Value
Worksheets("ES19W").Range("i9").Value = TextBox2.Value
Worksheets("ES19W").Range("z7").Value = TextBox3.Value
Worksheets("ES19W").Range("z11").Value = TextBox4.Value
-
Oct 5th, 2009, 09:13 AM
#44
Re: Code Dont work
Check this Example by Hack and implement it in your code 
http://www.vbforums.com/showpost.php...35&postcount=2
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 5th, 2009, 10:11 AM
#45
Thread Starter
Hyperactive Member
Re: Code Dont work
ok sorted the code out just changed additem to text and it displays it fine now thanks,,,,
now all i need is my search code to descend search :s
-
Oct 5th, 2009, 10:30 AM
#46
Thread Starter
Hyperactive Member
Re: Code Dont work
Code:
Set r = Sheets("Database").UsedRange.Find(TextBox3.Value).Order1 = xlDescending
If Not r Is Nothing Then
this dont work and similar alterations dont work either, please help
-
Oct 5th, 2009, 03:26 PM
#47
Re: Code Dont work
from msdn (f1 for help)
SearchDirection Optional Variant. Can be one of the following XlSearchDirection constants: xlNext or xlPrevious. The default constant is xlNext.
if you do not have help installed, why not?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 5th, 2009, 04:06 PM
#48
Thread Starter
Hyperactive Member
Re: Code Dont work
Ok ill try it mate thanks
-
Oct 6th, 2009, 10:52 AM
#49
Thread Starter
Hyperactive Member
Re: Code Dont work
ok added the previous code to the end of that line and then, the textbox1 argument below......now has trouble...
also when returning time data to my textboxes it returns numbers, even though the cells are set for time display.
-
Oct 6th, 2009, 12:52 PM
#50
Re: Code Dont work
returning time data to my textboxes it returns numbers, even though the cells are set for time display.
I haven't gone thru the rest of the code... Let's say the time is in Cell A1 and you want to display it in Textbox1, they try this...
vb Code:
Textbox1.Text = Format(Range("A1").Value,"HH:MM:SS")
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 8th, 2009, 02:44 AM
#51
Thread Starter
Hyperactive Member
Re: Code Dont work
ok right i got this error.....application-defined or object defined error!
when this code runs...
Code:
Private Sub Search()
Set r = Sheets("Database").UsedRange.Find(TextBox3.Value).Previous
If Not r Is Nothing Then
TextBox1.Text = r.Offset(0, -2)
TextBox2.Text = r.Offset(0, -1)
TextBox3.Text = r.Offset(0)
TextBox4.Text = Format(Range("A1").Value, "HH:MM:SS") = r.Offset(0, 1)
TextBox5.Text = Format(Range("A1").Value, "HH:MM:SS") = r.Offset(0, 2)
TextBox6.Text = r.Offset(0, 3)
ComboBox1.Text = r.Offset(0, 4)
ComboBox2.Text = r.Offset(0, 5)
ComboBox3.Text = r.Offset(0, 6)
Worksheets("ES19").Range("i7").Value = TextBox1.Value
Worksheets("ES19").Range("i9").Value = TextBox2.Value
Worksheets("ES19").Range("z7").Value = TextBox3.Value
Worksheets("ES19").Range("z11").Value = TextBox4.Value
Worksheets("ES19").Range("b29").Value = ComboBox1.Value
Worksheets("ES19W").Range("i7").Value = TextBox1.Value
Worksheets("ES19W").Range("i9").Value = TextBox2.Value
Worksheets("ES19W").Range("z7").Value = TextBox3.Value
Worksheets("ES19W").Range("z11").Value = TextBox4.Value
Worksheets("ES19W").Range("b29").Value = ComboBox1.Value
i think its the .previous on the beginning search line that causes the problem because it works without that, but i need the search to go in that direction.
-
Oct 8th, 2009, 02:53 AM
#52
Re: Code Dont work
xlprevious is a constant, not a method or property, it has to be an argument passed to the find method
read the help file or search on line
also your textbox4 and 5 code is wrong
Last edited by westconn1; Oct 8th, 2009 at 04:26 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 9th, 2009, 04:10 AM
#53
Thread Starter
Hyperactive Member
Re: Code Dont work
THIS IS IT.zip
ok koolsid, here is the file i mentioned.
-
Oct 9th, 2009, 06:28 AM
#54
Re: Code Dont work
I will get to your time problem later. First let's tackle the .Find issue...
Is this what you want?
vb Code:
Private Sub Search() Dim myAddr As String, MyArray() As String, r As Range '~~> Get the used range address myAddr = Sheets("Database").UsedRange.Address '~~> Split the address to get the last cell MyArray = Split(myAddr, ":") '~~> Select the last cell Range(MyArray(1)).Select strSearch = Trim(TextBox3.Value) '~~> Using xlPrevious to find in reverse Set r = Cells.Find(What:=strSearch, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False _ , SearchFormat:=False) If Not r Is Nothing Then TextBox1.Text = r.Offset(0, -2) TextBox2.Text = r.Offset(0, -1) ' '~~> Your Rest of the code '
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 9th, 2009, 08:21 AM
#55
Thread Starter
Hyperactive Member
Re: Code Dont work
thats good does what i want it too, but that code caused textbox1 to return a figure now instead of text....
textbox1 - text - did display correctly - now displays a number instead of text
textbox2 - text - displays correctly
textbox3 - text - displays correctly
textbox4 - time - doesnt display correctly - displays a number instead of time
textbox5 - time - doesnt display correctly - displays a number instead of time
textbox6 - date - displays correctly
textbox7 - text - displays correctly
-
Oct 9th, 2009, 08:23 AM
#56
Re: Code Dont work
I just amended/worked on the .find issue...
I didn't check the code between
If Not r Is Nothing Then
Endif
Check if the offset code is correct for each one of them...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 9th, 2009, 10:17 AM
#57
Thread Starter
Hyperactive Member
Re: Code Dont work
yes i had a duplicate textbox1 there so now just the problem of getting 4 and 5 to show time no matter what cell the data comes from....
-
Oct 9th, 2009, 10:26 AM
#58
Re: Code Dont work
Try this
vb Code:
'
'~~> Your Rest of the code
'
TextBox4.Text = Format(r.Offset(0, 1), "HH:MM:SS")
TextBox5.Text = Format(r.Offset(0, 2), "HH:MM:SS")
'
'~~> Your Rest of the code
'
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 9th, 2009, 10:50 AM
#59
Thread Starter
Hyperactive Member
Re: Code Dont work
Darn It! why is it when u try it works so simply, yet i try everything everyway round and get nowhere thanks mate that is perfect and works a treat.
-
Oct 9th, 2009, 10:55 AM
#60
Re: Code Dont work
 Originally Posted by hensucker
Darn It! why is it when u try it works so simply, yet i try everything everyway round and get nowhere  thanks mate that is perfect and works a treat.

Hope all your queries are resolved?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 25th, 2009, 06:09 PM
#61
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|