Sheet 1 as ENTER VALUE
Sheet 2 as MY VALUE and DATA
Sheet value is referenced from Sheet1 Value using =Sheet1!E4
I want to avoid onclick Button event => as soon as value in sheet 1 changes to 10 then My value in sheet 2 changes to 10 => then taking the value which is changed in sheet 2 the macros should automatically detect the value change as occured then print of Data should happen that many times in column I
Module 1 my macros :
Sub mac()
Dim ws As Worksheet
Dim rDest As Range
Dim lCount As Long
Dim sValue As String
Set ws = ActiveWorkbook.ActiveSheet
Set rDest = ws.Range("I2")
With ws.Range(rDest, ws.Cells(ws.Rows.Count, rDest.Column).End(xlUp))
If .Row >= rDest.Row Then .ClearContents
End With
lCount = Val(ws.Range("E4").Value)
sValue = ws.Range("E8").Value
If lCount > 0 Then rDest.Resize(lCount) = sValue
End Sub
Sheet 2 : Code
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("E4"), Range(Target.Address)) Is Nothing Then
Call mac
End Sub
output : should be like this below Output Image: https://i.stack.imgur.com/voz7g.png