Need help editing my VBA code to retreive values not equal to zero

mahoney403

New Member
Joined
Feb 20, 2013
Messages
30
Hi All,

I have a section in my macro that returns the values to a summary page whenever there is a value <>0 within a row. I was wondering, is there a way to exclude the cells that have a formula in them?(also, if there is, would =35 be considered a formula, in case the value was entered that way vs just "35").

Here is the piece of my code:

If ws.Name <> "Summary" Then
For c = 3 To 33 Step 1
If ws.Cells(39, c).Value <> 0 Then
i = i + 1
s(i, 1) = ws.Cells(4, c)
s(i, 2) = ws.Name
s(i, 3) = ws.Cells(39, c)
End If
Next c
End If

The columns I want to skip are the ones with subtotals, which is currently adding duplicates to my summary page. Also, the subtotals are throughout the row, not just the last column.

Any help is greatly appreciated,

Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi,

You can use a UDF such as

Code:
[COLOR=#333333]Function IsFormula(rng As Range)[/COLOR]
[COLOR=#333333]    If rng.HasFormula Then IsFormula = True[/COLOR]
[COLOR=#333333]End Function[/COLOR]

HTH
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top