473,405 Members | 2,210 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,405 software developers and data experts.

Date: Gettin Previous Month

I am using VBA- through Excel sheet.
I want to populate one particular column with previous month's name and year in the format 'MMM-YY'- how can i do this??

Also, the excel is to be converted to CSV after that (i know to do this). But, i want it in the same format 'MMM-YY'- it shouldnt get converted to the date format of Excel (in number).

Thanks for all the help!
Apr 4 '08 #1
2 1337
kadghar
1,295 Expert 1GB
I am using VBA- through Excel sheet.
I want to populate one particular column with previous month's name and year in the format 'MMM-YY'- how can i do this??

Also, the excel is to be converted to CSV after that (i know to do this). But, i want it in the same format 'MMM-YY'- it shouldnt get converted to the date format of Excel (in number).

Thanks for all the help!
well, you'll have to change the column's excel's format. CVS will keep the date's format.

this might be of help:

Expand|Select|Wrap|Line Numbers
  1. Selection.NumberFormat = "mmm-\y\y"
I'll strongly recomend you to use Date Variables in VBA too, so you dont get all mixed up.
Apr 4 '08 #2
Hi,

I have changed the format of the date- but while converting it to CSV through VB code (cell by cell), the format gets lost.

This is the code that does that:
With Worksheets("ACTUALS")
For r = 1 To .Range("A65536").End(xlUp).Row
s = ""
For c = 1 To 27
If InStr(1, .Cells(r, c), ",") > 0 Then
s = s & """" & .Cells(r, c) & """" & ","
Else
s = s & .Cells(r, c) & ","
End If
'c = c + 1
Next c

a.writeline s 'write line
Next r
End With


Also, how i want to populate one column with the Month_year value (previous month).
How do i go about populating a column in Excel through VBA?

Thanks!


(im actually not a VB technology person.. but am in Data warehousing...so appreciate all the help i can get)
Apr 9 '08 #3

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

Similar topics

11
by: Jim | last post by:
I have been using the javascript below on a web page since last August to show the "Site updated" month only minus a month, which has been very successful, but January is showing a "undefined 2004"...
6
by: Piotr Pietrowski | last post by:
Hello everybody, I have a *big* problem. I thought its not that big problem for you professionals... Anyway, I have a begin date which has 3 dropdown boxes (day/Month/Year). The same for the...
2
by: mirza i | last post by:
thanks for the previous replies. here is the new question (i'm absolutely sure that this should be VERY easy for a good js coder) ok: from asp i call: <img src="pics/cal.gif"...
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
13
by: Sue | last post by:
I'm working on a database that keeps track of employees hired by a general contractor on a project by project basis. These employees are hired to work on a project and are then laid off either at...
3
by: Vivian Dunn | last post by:
Can anyone please help with what I am sure is actually a very simple question. In the charity, that I work for, I use a database which records the support that we give to our clients. One of the...
7
by: Drygast | last post by:
I have a form where I would like to get the todays date and when the date is 15 or less I would like to assign a textfield the last date of previous month and when the date is larger then 15 I...
3
by: Bob Sanderson | last post by:
I have a PHP web page which uses a HTML form. I would like to enter dates into the date fields using a JavaScript calendar, similar to the way phpMyAdmin does. Can anyone recommend a JavaScript...
10
by: ashore | last post by:
Guys, the line below just returned "Dec 07" as the date for one month back from today. Hardly life-threatening, but any thoughts? <?php print date("M `y", mktime(0, 0, 0, date("m")-1, date("d"),...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.