Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Index ranges by 1

Posted on 2013-11-26
Medium Priority
109 Views
Folks,
In my worksheet Range A4 = Range H2
Range H2 = Today()
I would like to be able to increase ranges A5 = A9 by A4+1
In other words if the date in A4 = 11/26/2013 the the dates in A5:A9 would be incremented by 1 day such that A5 = 11/27/2013...
0
Question by:Frank Freese
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 3

LVL 23

Expert Comment

ID: 39678827
Try:

in A5:

=\$A\$4+ROWS(\$A\$5:\$A5)

copied down
0

Author Comment

ID: 39678887
Whoops...my mistake. I'm not going down...going across. I'll try substitute Column for Row?
Also need in VBA format
0

LVL 23

Expert Comment

ID: 39678929
The formula would be:

=\$A\$4+COLUMNS(\$A\$5:A\$5)

simple macro:

``````Sub CummulativeDate()
For i = 2 To 6
Cells(4, i) = Cells(4, 1) + i - 1
Next i

End Sub
``````
0

Author Comment

ID: 39679035
Here's the code I'm using in my procedure:

``````Dim NextCell As Long
Range("A4") = Range("H2")
For NextCell = 2 To 8
Cells(4, NextCell) = Cells(4, 1) + NextCell - 1
Next NextCell
``````
What happens is that the first cell (B4) is correctly populated, but then I drop completly out of the sub to another sub and never get to the NextCell
0

Author Comment

ID: 39679056
I recorded a macro then copy the below code to my subprocedure and it worked.
``````Range("B4").Select
ActiveCell.FormulaR1C1 = "=RC[-1]+1"
Range("B4").Select
Selection.AutoFill Destination:=Range("B4:H4"), Type:=xlFillDefault
Range("B4:H4").Select
``````
Can I award points for being "close"?
0

LVL 23

Accepted Solution

NBVC earned 2000 total points
ID: 39679141
You can replace all of that with:

``````With Range("B4")
.FormulaR1C1 = "=RC[-1]+1"
.AutoFill Destination:=Range("B4:H4"), Type:=xlFillDefault
End With
``````
so that you eliminate the use of Select (which is known to be inefficient and redundant).
0

Author Closing Comment

ID: 39679309
good job! thanks
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to usâ€¦
###### Suggested Courses
Course of the Month9 days, 21 hours left to enroll