Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Differentiate between "" and Empty in array elements.

I have text files holding comma separated values.
They are like this:

"bla-bla",,,,"",,""
"",,,,bla-bla,,

Now what I have to do is change the "" values to Empty values, so ,"", will
become ,,
This is easy, but I also want to know how many files had such an alteration
done.
This now proves very difficult, because I can't differentiate between ,, and
,"",

I can't do the alterations directly in the text file as I have to check a
few things, which are best done in an array.

I put the text files in an array and then the following loop runs:

For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
arr(i, c) = Empty
bDoneClean = True
End If
Next
Next

The array has to be declared as a variant.
Because I can't differentiate bDoneClean becomes true even if the array
element was already empty, so I can't count how many files were altered.
I have tried numerous ways to differentiate this, but found nil that works.
Thanks for any advice.


RBS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Differentiate between "" and Empty in array elements.

Had another go and found the answer.
This does the trick:

For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
If Not arr(i, c) = 0 Then
arr(i, c) = Empty
bDoneClean = True
End If
End If
Next
Next


RBS


"RB Smissaert" wrote in message
...
I have text files holding comma separated values.
They are like this:

"bla-bla",,,,"",,""
"",,,,bla-bla,,

Now what I have to do is change the "" values to Empty values, so ,"",

will
become ,,
This is easy, but I also want to know how many files had such an

alteration
done.
This now proves very difficult, because I can't differentiate between ,,

and
,"",

I can't do the alterations directly in the text file as I have to check a
few things, which are best done in an array.

I put the text files in an array and then the following loop runs:

For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
arr(i, c) = Empty
bDoneClean = True
End If
Next
Next

The array has to be declared as a variant.
Because I can't differentiate bDoneClean becomes true even if the array
element was already empty, so I can't count how many files were altered.
I have tried numerous ways to differentiate this, but found nil that

works.
Thanks for any advice.


RBS


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Differentiate between "" and Empty in array elements.

For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
if Not isempty(arr(i,c)) then
arr(i, c) = Empty
bDoneClean = True
End If
Next
Next


to illustrate, vVal starts as uninitialized Variant:

vVal = empty
? vVal = ""
True
? isempty(vVal)
True
vVal = ""
? vVal = ""
True
? isempty(vVal)
False

--
Regards,
Tom Ogilvy




RB Smissaert wrote in message
...
I have text files holding comma separated values.
They are like this:

"bla-bla",,,,"",,""
"",,,,bla-bla,,

Now what I have to do is change the "" values to Empty values, so ,"",

will
become ,,
This is easy, but I also want to know how many files had such an

alteration
done.
This now proves very difficult, because I can't differentiate between ,,

and
,"",

I can't do the alterations directly in the text file as I have to check a
few things, which are best done in an array.

I put the text files in an array and then the following loop runs:

For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
arr(i, c) = Empty
bDoneClean = True
End If
Next
Next

The array has to be declared as a variant.
Because I can't differentiate bDoneClean becomes true even if the array
element was already empty, so I can't count how many files were altered.
I have tried numerous ways to differentiate this, but found nil that

works.
Thanks for any advice.


RBS



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Differentiate between "" and Empty in array elements.

Thanks.
I thought I had done that one and thought it didn't work, but it works as
well indeed.
It looks more logical than
If Not arr(i, c) = 0 Then

RBS


"Tom Ogilvy" wrote in message
...
For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
if Not isempty(arr(i,c)) then
arr(i, c) = Empty
bDoneClean = True
End If
Next
Next


to illustrate, vVal starts as uninitialized Variant:

vVal = empty
? vVal = ""
True
? isempty(vVal)
True
vVal = ""
? vVal = ""
True
? isempty(vVal)
False

--
Regards,
Tom Ogilvy




RB Smissaert wrote in message
...
I have text files holding comma separated values.
They are like this:

"bla-bla",,,,"",,""
"",,,,bla-bla,,

Now what I have to do is change the "" values to Empty values, so ,"",

will
become ,,
This is easy, but I also want to know how many files had such an

alteration
done.
This now proves very difficult, because I can't differentiate between ,,

and
,"",

I can't do the alterations directly in the text file as I have to check

a
few things, which are best done in an array.

I put the text files in an array and then the following loop runs:

For i = 1 To LR
For c = 1 To 35
If arr(i, c) = "" Then
arr(i, c) = Empty
bDoneClean = True
End If
Next
Next

The array has to be declared as a variant.
Because I can't differentiate bDoneClean becomes true even if the array
element was already empty, so I can't count how many files were altered.
I have tried numerous ways to differentiate this, but found nil that

works.
Thanks for any advice.


RBS




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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I change color of "active" cell to differentiate from rest devildog97 Excel Discussion (Misc queries) 9 May 1st 08 03:25 PM
Adding new elements to an existing "list" aj Excel Worksheet Functions 1 May 15th 07 09:47 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
Excel 2007 PivotTable "arbitrary shape is not allowed when its elements cross a reference dimension" Michael Excel Discussion (Misc queries) 0 July 20th 06 06:00 PM
Excel: How to import multiple XML "Repeating child elements" same. l8vj Excel Worksheet Functions 0 May 13th 06 12:52 AM


All times are GMT +1. The time now is 03:27 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"