MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Create Excel Function with Visual Basic

  Asked By: Ashan    Date: Jan 03    Category: MS Office    Views: 2375

I am not a programmer, but I need help to create a function for Excel
that will allow me to check the numeric value of a cell, if the cells
value equals or is less than 0, Clear that cells contents as well as
cells located next to it.

I have become very good at macros but in this situation, I need to be
able to clear out the cells prior to sorting. This will allow me to
combine other data and output the final information using a pivot table.

Currently there are 40 cells in a block starting at B49:D89. The
numeric data to be examined is always located in column B. Column B
and the adjacent cells in C and D all need to have their cells cleared
when B#=<0.



2 Answers Found

Answer #1    Answered By: Alarice Miller     Answered On: Jan 03


Sub test()
Dim c

For Each c In Range("B49:B89")
If c.Value <= 0 Then
Range("B" & c.Row & ":D" & c.Row).Clear
End If
Next c
End Sub

Answer #2    Answered By: Frederik Jones     Answered On: Jan 03

Works great. Exactly what I wanted to do.

Didn't find what you were looking for? Find more on Create Excel Function with Visual Basic Or get search suggestion and latest updates.