473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

This line of code stopped working and I don't know why?

I am very new to excel vba and am trying to solve a problem in a coworkers code which has been dumped on my desk. It's just one line. We want the prior month to be inserted into cell I2 of a spreadsheet, but the following produces a debug error. I suspect it's the -1 portion because If I take that out the code will produce the value "JANUARY" in cell I2. Any suggestions would be greatly appreciated. Thank you!

Range("I2").Value = UCase(MonthName(Month(Date)-1))
Jan 12 '14 #1
1 960
Rabbit
12,516 Expert Mod 8TB
The month of January is the first month. 1 minus 1 is 0. Therefore you are trying to get the month name of month 0. There is no month 0, that's why you're getting an error. You need to use the if function to check for January.
Jan 13 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ralph | last post by:
Greetings. I've had the following code running perfectly on site for nearly 18 months and then on March 2, 2005 I started getting reports from users that my file download feature was broken. It's...
8
by: CsaaGuy | last post by:
My button events stopped working on a aspx form. Dont' know why. any suggestions?
4
by: JohnB111 | last post by:
Hi Environment: Windows XPPRO SP2 IIS 5.1 AVG Anti Virus (Not script Blocking) The following code used to work perfectly on my local development machine and still does on my web server.
2
by: hojjatnikan | last post by:
please help me this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
2
latitude
by: latitude | last post by:
Have had a few questions here but no replies so far so thought id give it one more go: Im working on a textviewer/editor and have used autodetect url on it, and it has worked fine. But somewhere...
2
by: rhyme2ri2 | last post by:
Hi!! I'm using asp.net 1.1 I have a datalist which gets dynamic data which is of unbound size may be small sometimes and may be very very long sometimes....... Whatever the size of data may be...
1
by: rickcasey | last post by:
I wonder if anyone has experienced something like this, as it seems truly bizarre and is causing me to tear out my hair (what little there is left of it).... The exec() function just suddenly...
1
by: waqasmgl | last post by:
Hi, I m confused about following ajax code. Where is the problem? Working good on IE but not on FireFox? Please sort it out. <script type="text/javascript"> function loadXMLDoc() { if...
2
matheussousuke
by: matheussousuke | last post by:
A while ago, the website was working, but now, the whole mysql stopped working, I mean, the website oppens, doesnt not show any connection errors, but I can't make any querry. If I try to login, I...
1
by: 315hughes | last post by:
Hi ive been given a database which i have been asked to add improved fuctionallity to the database. It currently does what is required. So ive got to work changing the front end. i have not moved any...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.