Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Based on this process:
Alternative procedure to copy a formula down for the range D22:D125: 1 Select the cell with the formula (D22) 2 In the Name box, change D22 to D22:D125 3 Press Enter to select 4 Press Ctrl-D (that's the Ctrl key and D together) Here's what I've got so far: Private Sub OK_Button_Click() Application.ScreenUpdating = False Dim i As Integer Set UserRange = Range(DataFill.Start_Cell) Range(DataFill.Start_Cell).Value = CInt(Beg_Val) End_Val = CInt(End_Val) Incr = CInt(Incr) Range(DataFill.Start_Cell).Select ActiveCell.Offset(1, 0).Select ActiveCell.FormulaR1C1 = "=R[-1]C+" & Incr Selection.Copy i = (End_Val / Incr) - 1 ActiveCell.Offset(i, 0).Activate Selection.FillDown Unload DataFill Application.ScreenUpdating = True End Sub I'm down to the point where I've selected and copied the formula. Now I want to highlight the cells down, based on the fomula for the variable "i" and then filldown the formula. I'm trying, and not having much luck by trying to accomplish this using some variant of "offset". Basically, what I want to do is: User input: Start_Cell Beg_Val End_Val Incr Where what happens from there is: Goto the Start_Cell Enter the Beg_Val Drop down one Cell Enter the formula = (One Cell Up) + Incr Value Copy this Cell Select, Highlight, or Activate Cells down based on an offset of: i = (End_Val / Incr) - 1 So, for: Start_Cell = E5 Beg_Val = 3 End_Val = 30 Incr = 3 i = (30/3) - 1 i = (10) - 1 i = 9 (Based on the way I've got this setup so far, the end value could be either -1 or -2 (i.e. (30/3) - 1 or (30/3) -2) depending on what works best for this) Would then drop down, highlight, select to E14 and copy or filldown the formula from E6 through to E14 creating the series: 3 - 30 in cells E5:E14 incremented by 3 So far, I'm not having much luck with this very last piece of the puzzle. Is this the best way to go about this? and Is this the most optimal code to write? Anyone? Thanx. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
selecting a range | Excel Discussion (Misc queries) | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
Selecting a Range | Excel Programming | |||
Selecting A Range | Excel Programming |