GerrardSVK
New Member
- Joined
- Sep 18, 2023
- Messages
- 29
- Office Version
- 2016
- Platform
- Windows
Dear all,
Can anyone help me?
I got exel where data are stored but I need to change them to be let say "Green".
I need to take data from E2;H9 and make them all to be filled just with max value 0,05.
There is also important to make this data as following
number 0,032 wil mean for me that the final result will be 0,050 x 32% = 0,16
If there will be number higher than 0,1 Mean for 100% there will be randomly generated value between 0,045 and 0,050
I wrote litle macro which should work but I think something is wrong.
I need to launch it from another exel because there is lot of exels than I need to modify like this.
Problem I think is format of copying data because there are data copied from merged rows I am not sure if this is problem.
Can anyone help me?
I got exel where data are stored but I need to change them to be let say "Green".
I need to take data from E2;H9 and make them all to be filled just with max value 0,05.
There is also important to make this data as following
number 0,032 wil mean for me that the final result will be 0,050 x 32% = 0,16
If there will be number higher than 0,1 Mean for 100% there will be randomly generated value between 0,045 and 0,050
I wrote litle macro which should work but I think something is wrong.
I need to launch it from another exel because there is lot of exels than I need to modify like this.
Problem I think is format of copying data because there are data copied from merged rows I am not sure if this is problem.
VBA Code:
Sub Makro2()
Dim KopyRange As String
KopyRange = Workbooks(1).Sheets(1).Range("B10").Value
Workbooks(2).ActiveSheet.Range(KopyRange).Copy
Workbooks(1).Sheets(2).Range(KopyRange).PasteSpecial
Dim Cell As Range
For Each Cell In Workbooks(1).Sheets(2).Range(KopyRange).Cells
Dim Hodnota As Double
Hodnota = ActiveCell.Value
If Hodnota < 0.1 Then
GoTo Aplikace
Else
Hodnota = (WorksheetFunction.RandBetween(45, 50) / 1000)
GoTo Aplikace
End If
Aplikace:
Dim Generation As Double
Generation = Hodnota * 10
ActiveCell.Offset(0, 10).Select
ActiveCell.Value = 50 * Generation
Dim Returned As Double
Returned = ActiveCell.Value
ActiveCell.Offset(0, -10).Select
ActiveCell.Value = Returned
Next
Workbooks(1).Sheets(2).Range(KopyRange).Copy
Workbooks(2).ActiveSheet.Range(KopyRange).PasteSpecial
End Sub