Hello Frinds
i want to make some changing in my account.
i want if bu8<>0 then it copy the value of selected range from sheet 1 to sheet 2.
i don't know about vba. my friend says me it will be by event change in my main updatedata but i don't know how to write code for it.
as you can see that data is keep copying after every 5 second i want it copy only if condition is met.
if bu8<> then copy only
Sub calculate_range()
Range("aj2:aj18").Calculate
Application.OnTime DateAdd("S", 2, Now), "calculate_range"
End Sub
Sub UpdateData()
If Range("bu8").Value > 0 Then
Application.OnTime Now + TimeValue("0:0:5"), "UpdateData", False
Else
Application.OnTime Now + TimeValue("0:0:5"), "UpdateData"
CopyData
End If
End Sub
Sub CopyData()
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim cRng As Range
Dim dCol As Long
Set sht1 = ThisWorkbook.Sheets("Sheet1")
Set sht2 = ThisWorkbook.Sheets("Sheet2")
Set cRng = sht1.Range("Bu1:bu8")
dCol = sht2.Cells(2, Columns.Count).End(xlToLeft).Column + 1
sht2.Range(Cells(2, dCol).Address, Cells(8, dCol + 1).Address) = cRng.Value
End Sub
i want to make some changing in my account.
i want if bu8<>0 then it copy the value of selected range from sheet 1 to sheet 2.
i don't know about vba. my friend says me it will be by event change in my main updatedata but i don't know how to write code for it.
as you can see that data is keep copying after every 5 second i want it copy only if condition is met.
if bu8<> then copy only
Sub calculate_range()
Range("aj2:aj18").Calculate
Application.OnTime DateAdd("S", 2, Now), "calculate_range"
End Sub
Sub UpdateData()
If Range("bu8").Value > 0 Then
Application.OnTime Now + TimeValue("0:0:5"), "UpdateData", False
Else
Application.OnTime Now + TimeValue("0:0:5"), "UpdateData"
CopyData
End If
End Sub
Sub CopyData()
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim cRng As Range
Dim dCol As Long
Set sht1 = ThisWorkbook.Sheets("Sheet1")
Set sht2 = ThisWorkbook.Sheets("Sheet2")
Set cRng = sht1.Range("Bu1:bu8")
dCol = sht2.Cells(2, Columns.Count).End(xlToLeft).Column + 1
sht2.Range(Cells(2, dCol).Address, Cells(8, dCol + 1).Address) = cRng.Value
End Sub