#1   Report Post  
maya
 
Posts: n/a
Default ques

Hi.

I new in vba+excell

I need to check if any data was inserted in column 13D - 19D
so I wrote:

Private Function check() As Boolean
Dim intCodeIndex As Integer
Dim checkCode As Boolean

intCodeIndex = 13
checkCode = False

While Not Cells(intCodeIndex, "D") = vbNullString ' I need to
improve this line.
checkCode = True
GoTo SUB_EXIT
intCodeIndex = intCodeIndex + 1
Wend

checkCode = False

SUB_EXIT:
check = checkCode

End Function

I need one value in column "D" - so the func return true.

the problem is - if there is not value in row13 the func return false -
although there could be value in row 19.

in order to return FALSE there must be no value in any row 13-19

how can I improve it to be fast and check all the row in column "D".

Thanks.

  #2   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi

Define a named range (Insert - Name - Define from menu), p.e. Check
Check=(COUNTIF(Sheet1!$D$13:$D$19,"<")0)

Now anywhere in workbook, you can check for any numeric or character entry
in range Sheet1!$D$13:$D$19 like this:
=IF(Check, Expression1, Expression2)

In VBA, you can check for entries in same range like this:
If [Check] then
Statements
Else
Statements
End If


Arvi Laanemets


"maya" wrote in message
...
Hi.

I new in vba+excell

I need to check if any data was inserted in column 13D - 19D
so I wrote:

Private Function check() As Boolean
Dim intCodeIndex As Integer
Dim checkCode As Boolean

intCodeIndex = 13
checkCode = False

While Not Cells(intCodeIndex, "D") = vbNullString ' I need to
improve this line.
checkCode = True
GoTo SUB_EXIT
intCodeIndex = intCodeIndex + 1
Wend

checkCode = False

SUB_EXIT:
check = checkCode

End Function

I need one value in column "D" - so the func return true.

the problem is - if there is not value in row13 the func return false -
although there could be value in row 19.

in order to return FALSE there must be no value in any row 13-19

how can I improve it to be fast and check all the row in column "D".

Thanks.



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



All times are GMT +1. The time now is 09:10 PM.

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"