VBA Syntax

Jym396

Board Regular
Joined
Jan 15, 2007
Messages
72
Office Version
  1. 2007
Platform
  1. Windows
I'm tryin' here...just can't get it...
Using this formula in the worksheet:
=IF(INDEX(B388:B404,MATCH(TODAY(),C388:C404,0))<>"","N","Y")
And it works just fine. Just can't seem to get the VBA syntax right. Do I need to use the
Application.Application.WorksheetFunction.Index(Sheets("Timesheet").Range("B388...etc
Application.Application.WorksheetFunction.Match ...etc.
Do I need those before every function?

Thanks a lot,
Jim
 
Re: VBA Syntax Help

The formula line is exactly the same line you said worked in post number 8, it hasn't changed :confused:
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Re: VBA Syntax Help

Question, do you only get the error when you are stepping through the code with F8 and not when doing a straight run?
 
Upvote 0
Re: VBA Syntax Help

@Jym396
A few questions.
1) do you want the formula inserted into col F?
2) if yes to above should it be done before or after checking if col E is blank?
3) You've said
I think it crashes on the formula statement.
Do you get any error messages? If so click debug.
Then please tell us the error message & which line is highlighted in yellow
 
Upvote 0
Re: VBA Syntax Help

The problem is the formula. I only used it sheet to see if I could today and then offset it. It doesn't belong in the VBA. I THINK I'm looking for a :

If ....code... then

Sorry such a poor VBA programmer.
 
Upvote 0
Re: VBA Syntax Help

I would recommend avoiding the use of VBA keywords as variables, as it can cause problems. Hence I've changed your variable cell to Cl
The OP used the variable name "Cell" which is not a VBA keyword (no "s" on the end). While "Cell" is really close to the VBA keyword "Cells", and I know many frown on using it, I tend to use "Cell" as a variable name all the time as I think it makes the code more self-documenting than a name like "Cl" does. If I were going to suggest an alternative, I might conside "Cel" as that is close enough to the actual word to still make it self-documenting (although my tendency for being somewhat obsessive-compulsive make it hard for me to use that variable name within my own code).
 
Upvote 0
Re: VBA Syntax Help

The problem is the formula. I only used it sheet to see if I could today and then offset it. It doesn't belong in the VBA.

What do you actually want to put in the cell 3 to the right of the cell with today's date if not the formula?

Explain very carefully exactly what you want to achieve as an end result.
 
Last edited:
Upvote 0
Re: VBA Syntax Help

Luv the name..Fluff.
1) No. I do not want the formula inserted.
2)It should be done right after the 'next'.

Abort sub if cell is not blank.

I think, an if then.
If blank...proceed.
If not blank...abort.
 
Last edited:
Upvote 0
Re: VBA Syntax Help

The OP used the variable name "Cell" which is not a VBA keyword (no "s" on the end). While "Cell" is really close to the VBA keyword "Cells", and I know many frown on using it, I tend to use "Cell" as a variable name all the time as I think it makes the code more self-documenting than a name like "Cl" does. If I were going to suggest an alternative, I might conside "Cel" as that is close enough to the actual word to still make it self-documenting (although my tendency for being somewhat obsessive-compulsive make it hard for me to use that variable name within my own code).
Must admit I always thought that both Cell & Cells were keywords. Thanks for the correction.:)
 
Upvote 0
Re: VBA Syntax Help

Luv the name..Fluff.
1) No. I do not want the formula inserted.
2)It should be done right after the 'next'.

Abort sub if cell is not blank.

Your posts are very confusing, what do you actually want to happen in the loop?
If you put the test outside the loop then it will just loop to C464 then exit if A464 isn't blank not when the cell with today's date is found.
It should be done right after the 'next'.
What is "it" in the above quote?

Again.

Explain very carefully exactly what you want to achieve as an end result.
(and in detail).
 
Last edited:
Upvote 0
Re: VBA Syntax Help

Must admit I always thought that both Cell & Cells were keywords. Thanks for the correction.:)
I guess I should mention that, technically, "Cells" is not a VBA keyword, rather, it is an Excel object property name (there is that tendency of mine to be somewhat obsessive-compulsive rearing its ugly head again:lol:) although I will admit this is a difference without a real distinction give the underlying caution you were trying to give to the OP.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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