Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default VBA code store address with areas separated with "," and I need it sometimes with ";" instead

VBA and Excel GUI aren't syncronised

CODE 1:
MsgBox Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt need
areas separated by ";"

CODE 2:
" IF Sheet2.Range("A1").Value<
Columns("V:V").SpecialCells(xlCellTypeFormulas, 1).Rows.Address
Then ..." need areas separated by ","

- why and can I do something about it?


I try to count the number of cells defined as a range in a cell in a
worksheet with MsgBox
Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt . The A1 cell
value could be like:
"$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$ V$100:$V$117,$V
$124:$V$140"

When I let the VBA code store an range address, I get the areas
separated with comma",". Because of the language defined in the Excel
GUI, they should be separated with semicomma ";"

I ran a "," find/replaced by ";" in the cell with the address, and
after the MsgBox Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt
worked all right.'''

Hmm, now I dont know what to do. I use the content in the cell with
other subs to compare like
" IF Sheet2.Range("A1").Value<
Columns("V:V").SpecialCells(xlCellTypeFormulas, 1).Rows.Address
Then ..." and it work OK. I guess this code won't work if I (by
code) replace the cell content from "," to ";".


What could I do?

Kind regards,
Tskogstrom

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA code store address with areas separated with "," and I need itsometimes with ";" instead

#1.

I didn't have any trouble with your first code with:
$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$V $100:$V$117,$V$124:$V$140
in A1.

The msgbox returned 103 for me. But I use the comma as the windows list
separator under my regional settings.

So I saved the workbook.
Closed excel.
And changed that list separator to a semi colon.
I reopened excel.
I reopened that saved workbook and ran the code and still got 103.

So I don't think your statement about #1 is true.

If you tried:

debug.print Range("$V$10:$V$25,$V$33:$V$48,$V$54:$V$71," _
& "$V$77:$V$94,$V$100:$V$117,$V$124:$V$140").cells.c ount

What do you get returned in the immediate window?

In fact, if you do:
debug.print Range("a1,b9").cells.count
what happens?

I think something else is going wrong--maybe a typo in A1 so that the value
doesn't look like an address of a range?????

====

#2.
When I tested with both the comma and semicolon, the .address returned the
addresses with each area separated by commas.

If you do:
debug.print range("a1,b9").address
what do you see in the immediate window?

tskogstrom wrote:

VBA and Excel GUI aren't syncronised

CODE 1:
MsgBox Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt need
areas separated by ";"

CODE 2:
" IF Sheet2.Range("A1").Value<
Columns("V:V").SpecialCells(xlCellTypeFormulas, 1).Rows.Address
Then ..." need areas separated by ","

- why and can I do something about it?

I try to count the number of cells defined as a range in a cell in a
worksheet with MsgBox
Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt . The A1 cell
value could be like:
"$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$ V$100:$V$117,$V
$124:$V$140"

When I let the VBA code store an range address, I get the areas
separated with comma",". Because of the language defined in the Excel
GUI, they should be separated with semicomma ";"

I ran a "," find/replaced by ";" in the cell with the address, and
after the MsgBox Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt
worked all right.'''

Hmm, now I dont know what to do. I use the content in the cell with
other subs to compare like
" IF Sheet2.Range("A1").Value<
Columns("V:V").SpecialCells(xlCellTypeFormulas, 1).Rows.Address
Then ..." and it work OK. I guess this code won't work if I (by
code) replace the cell content from "," to ";".

What could I do?

Kind regards,
Tskogstrom


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default VBA code store address with areas separated with "," and I need it sometimes with ";" instead

Does the cell have quotes ( "....") in it or not ?

Debug.Print Sheets("Sheet2").Range("A1")
Debug.Print Range(Sheets("Sheet2").Range("A1").Value).Cells.Co unt

$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$V $100:$V$117,$V$124:$V$140,$V$147:$V$163,$V$165:$V$ 233,$V$238:$V$289
241

Debug.Print Sheets("Sheet2").Range("A1")
Debug.Print Range(Sheets("Sheet2").Range("A1").Value).Cells.Co unt

"$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$ V$100:$V$117,$V$124:$V$140"

$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$V $100:$V$117,$V$124:$V$140
103

The middle version, with the quotes, gives an error

Regards

Trevor


"tskogstrom" wrote in message
oups.com...
VBA and Excel GUI aren't syncronised

CODE 1:
MsgBox Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt need
areas separated by ";"

CODE 2:
" IF Sheet2.Range("A1").Value<
Columns("V:V").SpecialCells(xlCellTypeFormulas, 1).Rows.Address
Then ..." need areas separated by ","

- why and can I do something about it?


I try to count the number of cells defined as a range in a cell in a
worksheet with MsgBox
Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt . The A1 cell
value could be like:
"$V$10:$V$25,$V$33:$V$48,$V$54:$V$71,$V$77:$V$94,$ V$100:$V$117,$V
$124:$V$140"

When I let the VBA code store an range address, I get the areas
separated with comma",". Because of the language defined in the Excel
GUI, they should be separated with semicomma ";"

I ran a "," find/replaced by ";" in the cell with the address, and
after the MsgBox Range(Sheets("Sheet1").Range("A1").Value).Cells.Co unt
worked all right.'''

Hmm, now I dont know what to do. I use the content in the cell with
other subs to compare like
" IF Sheet2.Range("A1").Value<
Columns("V:V").SpecialCells(xlCellTypeFormulas, 1).Rows.Address
Then ..." and it work OK. I guess this code won't work if I (by
code) replace the cell content from "," to ";".


What could I do?

Kind regards,
Tskogstrom



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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... Maria J-son[_2_] Excel Programming 2 March 5th 06 12:20 PM


All times are GMT +1. The time now is 04:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"