Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How my macro will work is, I input a set integers (row numbers) seperated by commas and I will split up these numbers into seperate cells.

Then, using a loop I will use the row numbers and update the rows accordingly.

Seperate input data into seperate numbers and insert them into seperate cells on first row of sheet
VB
Sub btnResetSelected()


Dim resetRow As String
Dim i As Integer
Dim Rows As Variant

'To get seperate rows from cell seperated by comma
resetRow = Range("C10").Value

Rows = Split(resetRow, ",")

For i = 0 To UBound(Rows)

Cells(1, i + 1).Value = Rows(i)

Next i


End Sub


What I have now for the insertion of formula:
VB
Dim resetRow1 As Integer
Dim resetRow2 As Integer

resetRow1 = Range("A1").Value

Range("F" & (resetRow1) & ":I" & (resetRow1)).Formula = "=G10_Anchor+short_end_increment*(base_year-F$57)"

resetRow2 = Range ("A2").Value

Range("F" & (resetRow2) & ":I" & (resetRow2)).Formula = "=G10_Anchor+short_end_increment*(base_year-F$57)"


I do not want to hard code this for every cell just in case the user inputs a lot of seperate integers into the cell, will a loop work/help?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900