I am creating a dash board in excel but however i would like to know if there is a better way of coding rather than this. I would like to moduleriz it instead of doing this to m
Well, just purely based on this particular piece of code of yours, you could try something along the following lines:
Option Explicit
Sub Sample()
Dim rng As Range
Dim x As Long
Dim arr As Variant
With Sheet1
'Input static values
.Cells(35, "C").Value = .[C57]
'Prepare for dynamic values
Set rng = .Range("D35:H35")
arr = Array(1.3, 1.02, 1.9, 1.9, 1.5)
'Insert dynamic values
For x = 1 To rng.Cells.Count
rng.Cells(1).Value = WorksheetFunction.Round(rng.Cells(1).Value * arr(x - 1), 0)
Next x
End With
End Sub
Or, if your concatenated string won't go over 255 characters:
Sub Sample()
Dim str As String
With Sheet1
'Input static values
.Cells(35, "C").Value = .[C57]
'Prepare for dynamic values
str = "{1.3,1.02,1.9,1.9,1.5}"
'Insert dynamic values
.Range("D35:H35").Value = .Evaluate("D35:H35*" & str)
End With
End Sub