Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Simple CountA syntax (VBA)

I have a worksheet where users are entering data from D1 to IV1 (headers); I
need to count how many entries exist so I can automatically paste entries at
the next unused cell (all contiguous cells will be filled, There won't be
any blanks).

I tried the following, but the range reference for CountA doesn't appear to
translate well (clearly, I'm not getting the proper syntax).

Can anyone correct it, or provide an easy alternative in VBA?
Thanks,
Keith
XL2003

not working:
-----------------
OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1"))
and
OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1").value)

Each returns the value of 1; in a cell on that worksheet, =countA(D1:IV1)
evaluates to 34 (and will be growing quickly)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Simple CountA syntax (VBA)

Demo'd from the immediate window:

OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1"))
? oldapps
6

works fine for me. Sheet3 refers to a sheet with the code name of Sheet3.
I would guess that you want the sheet with a tab name of sheet3. (while
these usually match in a new workbook, they certainly don't have to).

Try this

Dim rng as range
set rng = Worksheets("Sheet3").Range("D1:IV1")
OldApps = Excel.WorksheetFunction.CountA(rng)

another way to know where to enter the value

Dim rng1 as Range
set rng1 = worksheets("Sheet3").Range("IV1").End(xltoLeft)
if rng1.column 3 then
rng1.offset(0,1).Value = "NewHeader"
else
worksheets("Sheet3").Range("D1").Value = "NewHeader"
End if

--
Regards,
Tom Ogilvy


"Keith" wrote:

I have a worksheet where users are entering data from D1 to IV1 (headers); I
need to count how many entries exist so I can automatically paste entries at
the next unused cell (all contiguous cells will be filled, There won't be
any blanks).

I tried the following, but the range reference for CountA doesn't appear to
translate well (clearly, I'm not getting the proper syntax).

Can anyone correct it, or provide an easy alternative in VBA?
Thanks,
Keith
XL2003

not working:
-----------------
OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1"))
and
OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1").value)

Each returns the value of 1; in a cell on that worksheet, =countA(D1:IV1)
evaluates to 34 (and will be growing quickly)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Simple CountA syntax (VBA)

Thanks Tom- I'm going to use the xltoLeft, I like that solution!

"Tom Ogilvy" wrote in message
...
Demo'd from the immediate window:

OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1"))
? oldapps
6

works fine for me. Sheet3 refers to a sheet with the code name of Sheet3.
I would guess that you want the sheet with a tab name of sheet3. (while
these usually match in a new workbook, they certainly don't have to).

Try this

Dim rng as range
set rng = Worksheets("Sheet3").Range("D1:IV1")
OldApps = Excel.WorksheetFunction.CountA(rng)

another way to know where to enter the value

Dim rng1 as Range
set rng1 = worksheets("Sheet3").Range("IV1").End(xltoLeft)
if rng1.column 3 then
rng1.offset(0,1).Value = "NewHeader"
else
worksheets("Sheet3").Range("D1").Value = "NewHeader"
End if

--
Regards,
Tom Ogilvy


"Keith" wrote:

I have a worksheet where users are entering data from D1 to IV1
(headers); I
need to count how many entries exist so I can automatically paste entries
at
the next unused cell (all contiguous cells will be filled, There won't be
any blanks).

I tried the following, but the range reference for CountA doesn't appear
to
translate well (clearly, I'm not getting the proper syntax).

Can anyone correct it, or provide an easy alternative in VBA?
Thanks,
Keith
XL2003

not working:
-----------------
OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1"))
and
OldApps = Excel.WorksheetFunction.CountA(Sheet3.Range("D1:IV 1").value)

Each returns the value of 1; in a cell on that worksheet, =countA(D1:IV1)
evaluates to 34 (and will be growing quickly)





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
COUNTA function causing syntax error in macro... Birmangirl Excel Worksheet Functions 4 February 6th 07 04:04 PM
question about syntax in a simple macro... Dave F Excel Discussion (Misc queries) 3 November 3rd 06 02:12 PM
COUNTA Function not working =COUNTA(C3:C69,"NH") MikeinNH Excel Worksheet Functions 2 November 8th 04 01:19 AM
Syntax error (simple) Jack Schitt Excel Programming 4 September 3rd 04 04:35 PM
need help with simple syntax error Gwill Excel Programming 1 July 15th 03 08:24 AM


All times are GMT +1. The time now is 11:22 AM.

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"