ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Easy code!!!! (https://www.excelbanter.com/excel-programming/291630-easy-code.html)

SUDHENDRA

Easy code!!!!
 
Hi

Can this code be written in one line!!!! thanks in advance

If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
ElseIf ZoneNo = 1 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 2 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 3 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 4 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 5 Then
sREPORT_CODE = Format
(ZoneNo, "000")
End If

Jake Marx[_3_]

Easy code!!!!
 
Hi Sudhendra,

Yes:

If InStr(1, ZoneNo, "us", vbTextCompare) Then _
sREPORT_CODE = "999" Else sREPORT_CODE = _
Format(ZoneNo, "000")

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Sudhendra wrote:
Hi

Can this code be written in one line!!!! thanks in advance

If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
ElseIf ZoneNo = 1 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 2 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 3 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 4 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 5 Then
sREPORT_CODE = Format
(ZoneNo, "000")
End If


Frank Kabel

Easy code!!!!
 
Hi
though not one line but try
If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
elseif ZoneNo = 1 and ZoneNo <=5 then
sREPORT_CODE = Format (ZoneNo, "000")
end if

--
Regards
Frank Kabel
Frankfurt, Germany

Sudhendra wrote:
Hi

Can this code be written in one line!!!! thanks in advance

If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
ElseIf ZoneNo = 1 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 2 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 3 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 4 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 5 Then
sREPORT_CODE = Format
(ZoneNo, "000")
End If


No Name

Easy code!!!!
 
Thanks

-----Original Message-----
Hi Sudhendra,

Yes:

If InStr(1, ZoneNo, "us", vbTextCompare) Then _
sREPORT_CODE = "999" Else sREPORT_CODE = _
Format(ZoneNo, "000")

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


Sudhendra wrote:
Hi

Can this code be written in one line!!!! thanks in

advance

If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
ElseIf ZoneNo = 1 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 2 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 3 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 4 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 5 Then
sREPORT_CODE = Format
(ZoneNo, "000")
End If

.


SUDHENDRA

Easy code!!!!
 
Thanks
-----Original Message-----
Hi
though not one line but try
If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
elseif ZoneNo = 1 and ZoneNo <=5 then
sREPORT_CODE = Format (ZoneNo, "000")
end if

--
Regards
Frank Kabel
Frankfurt, Germany

Sudhendra wrote:
Hi

Can this code be written in one line!!!! thanks in

advance

If (InStr(1, ZoneNo, "us", vbTextCompare) 0) Then
sREPORT_CODE = "999"
ElseIf ZoneNo = 1 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 2 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 3 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 4 Then
sREPORT_CODE = Format
(ZoneNo, "000")
ElseIf ZoneNo = 5 Then
sREPORT_CODE = Format
(ZoneNo, "000")
End If

.



All times are GMT +1. The time now is 07:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com