View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default VBA for Month and Quarters Output


How about this:
Sub BeginMonth()

Dim Mth As String
Dim Nbr As Long

Mth = InputBox("Please enter a beginning month.")

Range("C5").Select
ActiveCell = Mth

Nbr = CLng(Application.InputBox _
(prompt:="Please enter total number of months.", Type:=1))

Range("Z1").Select
ActiveCell = Nbr

Range("C5").Select
Selection.AutoFill Destination:=Range _
(Selection, Selection.Resize(1, Nbr))

End Sub

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Hugo" wrote:

Hi,

I am new to writing in VBA, but I would like to write a function, where the
inputs are a start date and an end date (month&year), and the output is a
range in a single row of an indefinite number of columns (to be determined by
how muhc time is between the starting date and the ending date). I would
like the output to be in the form of showing the month and year, and at the
end of every fiscal quarter showing the quarter and year. For example the
output would look like the following, where a comma shows where a break
between cells in a row occurs:

"Jan-2009, Feb-2009, Mar-2009, Q1-2009, Apr-2009,..."

Any tips would be greatly appreciated. I assume I will have to write this
as a function not a subroutine, but would appreciate hearing suggestions.

Thanks!
--
Hugo