Dear friends,
I have <acronym title="visual basic for applications">VBA</acronym> code for transfer of data to another sheet. it works fine. but if the command button is pressed two times, it transfer the data for two times.
I need <acronym title="visual basic for applications">VBA</acronym> code which will transfer data to another sheet based on "date" (every Month end date) criteria,
if the criteria is met, it should replace the data.
if the criteria is not met, it should transfer the data to the first empty row.
totally either the data either should be replaced or transferred to empty row.
the code for transferring data to another sheet is attached herewith
Sub TransferToAnotherSheet_Click()
Dim smallrng As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
Dim SourceRange As Range, i As Integer
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Sheets("Master").Range("A9:V10500")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("FinalMaster")
Lr = DestSheet.Cells(Rows.Count, "A").End(xlUp).Row
i = 1
For Each smallrng In SourceRange.Areas
'We make DestRange the same size as smallrng and use the
'Value property to give DestRange the same values
With smallrng
Set DestRange = DestSheet.Cells(Lr + 1, i) _
.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = smallrng.Value
i = i + smallrng.Columns.Count
MsgBox "The data has been successfully copied."
Next smallrng
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
I need a new <acronym title="visual basic for applications">VBA</acronym> code which will meet the both the criteria.
Thanks in advance.
I need <acronym title="visual basic for applications">VBA</acronym> code which will transfer data to another sheet based on "date" (every Month end date) criteria,
if the criteria is met, it should replace the data.
if the criteria is not met, it should transfer the data to the first empty row.
totally either the data either should be replaced or transferred to empty row.
the code for transferring data to another sheet is attached herewith
Sub TransferToAnotherSheet_Click()
Dim smallrng As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
Dim SourceRange As Range, i As Integer
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Sheets("Master").Range("A9:V10500")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("FinalMaster")
Lr = DestSheet.Cells(Rows.Count, "A").End(xlUp).Row
i = 1
For Each smallrng In SourceRange.Areas
'We make DestRange the same size as smallrng and use the
'Value property to give DestRange the same values
With smallrng
Set DestRange = DestSheet.Cells(Lr + 1, i) _
.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = smallrng.Value
i = i + smallrng.Columns.Count
MsgBox "The data has been successfully copied."
Next smallrng
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
I need a new <acronym title="visual basic for applications">VBA</acronym> code which will meet the both the criteria.
Thanks in advance.