EXTRA ZERO

Herman

New Member
Joined
Feb 28, 2002
Messages
28
I Have a worksheet where in column a there are productnumbers like 045444 but excel doesnt; show the first zero so i had to make a format like 000000
now in vba i want to take connect to an sql server and find the description which belongs to 045444 but activecell.text gives 045444 that;s what i want to lookup as a value but this is now a text and activecell.value gives 45444 (but i need the extra zero)how can i look up 045444 as a value in my sql databse. ?

can someone help
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
yes i connect through vba and this is my code
y should be the value with the zero in front

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 7-3-2002 by Plieger
bnumber = 0

Do While ActiveCell.Value <> 99999
bnumber = bnumber + 1
x = "b" & bnumber
With ActiveSheet.QueryTables.Add(Connection:="ODBC;DSN=proddta;", _
Destination:=Range(x))
y = ActiveCell.Text
.CommandText = Array( _
"SELECT f4101.imdsc1" & Chr(13) & "" & Chr(10) & "FROM AS400GOFI.PRODDTA.f4101 f4101" & Chr(13) & "" & _
Chr(10) & "WHERE (f4101.imlitm = " & y & ")" _
)
.Name = "Query from proddta"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
If ActiveCell.Value = "" Or ActiveCell.Value = "niet leverbaar" Then GoTo verder1
If ActiveCell.Value <> "" Or ActiveCell.Value <> "niet leverbaar" Then GoTo verder
verder1:
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
bnumber = bnumber + 1
GoTo verder:
verder:
Loop
End Sub
 
Upvote 0
The code generates an overflow

i don't know what the code exactly does but i have a text and want a number
does cint convert text to number ??
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top