LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Fill Right Variable Number of Columns, then Calculate Using Offset

I am stuck on (what is probably) a simple macro. I am trying to prompt a
user to enter a month into C14 and then enter a number (lets say 12 but it
varies) into another InputBox and then spread the months over that range.
This is what I have so far:

Sub BeginMonth()

Dim Mth As String
Dim Nbr As Long

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

Range("C14").Select
ActiveCell = Mth

Nbr = InputBox("Please enter total number of months.")

Selection.AutoFill Destination:=Range("C14:D14"), Type:=xlFillDefault
Range("C14:D14").Select

ActiveCell.Offset(0, Nbr).Activate

With ActiveSheet
.Range("C14").AutoFill Destination:=.Range("C14" & Nbr)
End With


End Sub


It fails on AutoFill line.

Also, Id like to do a simple calculation in cell C15, such as =(D10/E27).
Then, Id like to fill right as many columns as the user enters (as mentioned
above, perhaps 12, but it will vary). Finally, in C16, Id like to do
another simple calculation, such as =(C15*K10), and again fill right and then
shift right one column (Offset 0,1) and down one row, then right one column
and down two rows, and right one column and down 3 rows, etc., until it
reaches the final column (12 or whatever the user enters).

Im sure it can be done and Im taking a crack at it now. If anyone has any
suggestions, please share. If I finish it off before I hear back from anyone
Ill post the solution here.

Regards,
Ryan--

--
RyGuy
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate number of weeks a variable spans in [email protected] Excel Worksheet Functions 0 March 3rd 08 12:29 AM
sum number of columns based on variable value rt10516 Excel Discussion (Misc queries) 4 November 8th 07 01:47 PM
Fill variable number of cells with a fixed text Robert[_30_] Excel Programming 1 July 11th 07 11:24 AM
HIDING A VARIABLE NUMBER OF COLUMNS [email protected] Excel Programming 1 February 15th 07 09:14 PM
select offset (variable ,1) to offset(variable ,variable) Buffyslay Excel Programming 1 November 15th 06 11:45 AM


All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"