T
Thomp
Can someone look at this macro that I copied from a website and tell
me why the code is not working for me. My source data work sheets is
named "Input KPI" and my destination worksheet is named "KPI Dash2". I
get a sub or function not defined error when I try to run and it seems
to highlight the last row code. I have limited knowledge of VBA so
maybe I am doing something wrong.
I need to copy only non-blank cells in a certain range and have them
copy to another worksheets first empty row in a certain range
Not sure if this code will do that.
Here is the code I was trying to use.
thanks,
Bill
Sub Copy_1_Value_PasteSpecial()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Sheets("Input KPI").Range("A1:K1")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("KPI Dash2")
Lr = LastRow(DestSheet)
'With the information from the LastRow function we can
'create a destination cell
Set DestRange = DestSheet.Range("A" & Lr + 1)
'Copy the source range and use PasteSpecial to paste in
'the destination cell
SourceRange.Copy
DestRange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
me why the code is not working for me. My source data work sheets is
named "Input KPI" and my destination worksheet is named "KPI Dash2". I
get a sub or function not defined error when I try to run and it seems
to highlight the last row code. I have limited knowledge of VBA so
maybe I am doing something wrong.
I need to copy only non-blank cells in a certain range and have them
copy to another worksheets first empty row in a certain range
Not sure if this code will do that.
Here is the code I was trying to use.
thanks,
Bill
Sub Copy_1_Value_PasteSpecial()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Sheets("Input KPI").Range("A1:K1")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("KPI Dash2")
Lr = LastRow(DestSheet)
'With the information from the LastRow function we can
'create a destination cell
Set DestRange = DestSheet.Range("A" & Lr + 1)
'Copy the source range and use PasteSpecial to paste in
'the destination cell
SourceRange.Copy
DestRange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub