Solved: Excel Macro Explanation

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

computerman29642

Thread Starter
Joined
Dec 4, 2007
Messages
2,895
Could someone explain the code below?

Code:
Cells(8, Weekday(Date) + 2).Select
I understand that the code is looking at the 8th row, but I am a little confused on the ColumnIndex.
 
Joined
Jul 1, 2005
Messages
8,546
Weekday(Date) gives you a value from 1 to 7 according to the current day according to the PC clock. Since return type isn't specified, the default (Sunday = 1, Monday = 2, etc.) is used.

So if run today (Oct 7th 2008), weekday = Tuesday, i.e. 3. The +2 gives you 5, so the outcome is E8 selection.

Presumably there's other "stuff" in the first 7 rows/2 columns that's to be ignored. Other than that, actual selection may not be necessary depending on what goes before/comes next.

HTH
 
Joined
Jul 25, 2004
Messages
5,458
Two questions I have looking at that one line. Might be nothing, might be something.

Code:
Cells(8, Weekday(Date) + 2).Select
The range is not qualified as far as a sheet/book goes. And you're using Select. Ugh. Tell me you have a specific need to select something? :)

Okay, off soap box. :D
 

computerman29642

Thread Starter
Joined
Dec 4, 2007
Messages
2,895
LOL....

Yes, I have a specific need to select something. All the code does is select the current date/weekday so I can input my total hours of work. This code is used for my timesheet.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top