Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Testing dynamic range for values

I have a dynamic range in an Excel worksheet. In a VBA module I have a
routine that exports the values within the dynamic range to a CSV file. How
can I test to make sure there is at least one value (record) in the dynamic
range?

Ken
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Testing dynamic range for values

Dim rngTemp As Range
Set rngTemp = Range("A1:J10")

If WorksheetFunction.CountA(rngTemp) = 0 Then
'No records
Else
'Write to csv
End If


If this post helps click Yes
---------------
Jacob Skaria


"Ken Warthen" wrote:

I have a dynamic range in an Excel worksheet. In a VBA module I have a
routine that exports the values within the dynamic range to a CSV file. How
can I test to make sure there is at least one value (record) in the dynamic
range?

Ken

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Testing dynamic range for values

Jacob,

Thanks for your help. I tried the following but am getting an error on the
Set statement saying "Method 'Range' of object'_Global' failed."

Ken


Dim rng As Range

'clear any CSV worksheet data
With ThisWorkbook.Worksheets("CSV")
Set rng = Range("CSVExportRange")
If WorksheetFunction.CountA(rng) < 0 Then
For Each Cell In Range(rng)
If Cell.Value < "" Then
Cell.Value = ""
End If
Next Cell
End If
End With



"Jacob Skaria" wrote:

Dim rngTemp As Range
Set rngTemp = Range("A1:J10")

If WorksheetFunction.CountA(rngTemp) = 0 Then
'No records
Else
'Write to csv
End If


If this post helps click Yes
---------------
Jacob Skaria


"Ken Warthen" wrote:

I have a dynamic range in an Excel worksheet. In a VBA module I have a
routine that exports the values within the dynamic range to a CSV file. How
can I test to make sure there is at least one value (record) in the dynamic
range?

Ken

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Testing dynamic range for values

Dot (.) missing. Try the below

Dim rng As Range

'clear any CSV worksheet data
With ThisWorkbook.Worksheets("CSV")
Set rng = .Range("CSVExportRange")
If WorksheetFunction.CountA(rng) < 0 Then
For Each Cell In Range(rng)
If Cell.Value < "" Then
Cell.Value = ""
End If
Next Cell
End If
End With

If this post helps click Yes
---------------
Jacob Skaria


"Ken Warthen" wrote:

Jacob,

Thanks for your help. I tried the following but am getting an error on the
Set statement saying "Method 'Range' of object'_Global' failed."

Ken


Dim rng As Range

'clear any CSV worksheet data
With ThisWorkbook.Worksheets("CSV")
Set rng = Range("CSVExportRange")
If WorksheetFunction.CountA(rng) < 0 Then
For Each Cell In Range(rng)
If Cell.Value < "" Then
Cell.Value = ""
End If
Next Cell
End If
End With



"Jacob Skaria" wrote:

Dim rngTemp As Range
Set rngTemp = Range("A1:J10")

If WorksheetFunction.CountA(rngTemp) = 0 Then
'No records
Else
'Write to csv
End If


If this post helps click Yes
---------------
Jacob Skaria


"Ken Warthen" wrote:

I have a dynamic range in an Excel worksheet. In a VBA module I have a
routine that exports the values within the dynamic range to a CSV file. How
can I test to make sure there is at least one value (record) in the dynamic
range?

Ken

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 2003 dynamic named range for the values in a pie chart TSW632[_2_] Charts and Charting in Excel 1 March 3rd 12 08:46 PM
Source Data - Values - Dynamic Range possible? BR Charts and Charting in Excel 2 March 10th 09 10:23 AM
copy rows that do not match values in dynamic range. Zebrahead Excel Programming 2 March 13th 07 06:27 PM
Dynamic Range of Cell Values in a single Row KarenB Excel Discussion (Misc queries) 5 October 12th 06 09:11 PM
paste values from named dynamic range to another worksheet Nate H Excel Programming 2 January 25th 06 06:50 PM


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