|
-
Apr 11th, 2008, 12:04 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Checking the length of the letterin excel
i am checking the legth of the cell has 5 do someting and greater than 5 it displays the message and stops the macro the macro shows here:
but it gives object error code
but i have in cell 4 e has 5 letter
if Len(aSheet.Cells(4,"e",5)) Then
MyScreen.Area(1,10,1,14).Value = aSheet.Cells(4, "e").Value
ElseIf Len(aSheet.Cells(4, "e").value) > 5 Then
MsgBox ("Corp should be 5 letters in Excel sheet ")
-
Apr 11th, 2008, 12:06 PM
#2
Re: Checking the length of the letterin excel
What is the exact error and on what line does it occur?
-
Apr 11th, 2008, 01:28 PM
#3
Thread Starter
Addicted Member
Re: Checking the length of the letterin excel
Len(aSheet.Cells(4,"e",5))
OBJECT code error
but in excel it is 5 letters only
-
Apr 11th, 2008, 04:05 PM
#4
Re: Checking the length of the letterin excel
Is this what you are trying?
Code:
If Len(Trim(aSheet.Cells(4, 4).Value)) < 5 Then
'your code
ElseIf Len(Trim(aSheet.Cells(4, 4).Value)) > 5 Then
MsgBox ("Corp should be 5 letters in Excel sheet ")
End If
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
-
Apr 11th, 2008, 06:27 PM
#5
Thread Starter
Addicted Member
Re: Checking the length of the letterin excel
yes i tried the same thing but = 5
-
Apr 11th, 2008, 06:28 PM
#6
Thread Starter
Addicted Member
Re: Checking the length of the letterin excel
what is actually trim will do
-
Apr 12th, 2008, 12:05 AM
#7
Re: Checking the length of the letterin excel
trim remove space/s at beginning and end of string
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
-
Apr 13th, 2008, 04:58 AM
#8
Re: Checking the length of the letterin excel
 Originally Posted by india123
yes i tried the same thing but = 5
Sorry i don't understand...
Is this what you want?
vb Code:
'if less than 5
If Len(Trim(aSheet.Cells(4, 4).Value)) < 5 Then
'your code
'if greater than 5
ElseIf Len(Trim(aSheet.Cells(4, 4).Value)) > 5 Then
MsgBox ("Corp should be 5 letters in Excel sheet ")
'if equal to 5
ElseIf Len(Trim(aSheet.Cells(4, 4).Value)) = 5 Then
'your code
End If
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
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
|