Jump to content

Excell Formula question


Zolar V

Recommended Posts

Hey guys, I am trying to script a cell block to do this

 

Cell x = Cell y - Cell z

 

IF (cell x = - (integer)

IF TRUE then print N/A

IF FALSE then Cell y - Cell z

 

 

My question is how to name the Interger, i thought VAR would work but i guess not

I dont want it to refer to a specific negative integer i just the function to read whether it is positive or negative.

 

NVM i got it. decided to go the greater than / less than rout.

Though i do wish i knew the term for the variables in the code. ugh.

 

New question now, How do i set conditional formatting?

I want some cells to only format to General is a cell is text, If not i want it to format to Time.

 

UGH so i tried formating it with the special formatting tool and that isn't quite working

Could anyone help with trying to make a subroutine?

i got this but its not correct

 

 

Private Sub sheet_1()

If F4ISTEXT Then

set format (CELLG4,[NUMBER])

AND Format (I4,[NUMBER])

End Sub

 

the if is supposed to be ISTEXT(F4) but it doesn't seem to like that, it says its undefined.

ISTEXT(F4) is the script within excel that you can use to define whether or not to do something if F4 is text. Basicaly the function asks if the cell is text then outputs true or false.

 

It doesnt like CellG4, Cell $G$4, G4 either. and i am pretty sure it wants more for the format function syntax.

Link to comment
Share on other sites

"cells(i,j)" where i is column number, and j is the row number is what you are looking for. Then, you'll have to use the property of the cells range, either

 

Cells(i,j).Value or cells(i,j).Forumula, etc. depending on what you want to use.

 

Though, you don't need a VBA program to do this for you, why not just use Excel's built-in function IF?

Edited by Bignose
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.