Hi,
with the code below i am trying to find a specific cell, offset it and paste from cell c11 and c13.
i've set the coloumn AE as the counter column (this part of the code works fine it finds the last row and add 1 to value of the previous.
but the paste part of the code keeps on pasting the values from c11 and c13 in row 45,
ie. the last row of AE will be row 3 but the pasting will still be on row 45
any help please.
Private Sub editprice_Click()
Dim rngFindValue As Range
Dim rngSearch As Range
Dim rngFind As Range
Dim lastrow As Long
On Error Resume Next
Application.ScreenUpdating = False
Set rngFind = ActiveSheet.Range("AD22:ZE22") 'search in this range of cells
Set rngSearch = rngFind.Cells(rngFind.Cells.Count) 'get the number of cells in this column
Set rngFindValue = rngFind.Find(Range("c9").Value, rngSearch, xlValues) 'search for the value that in cell c9
'================================================================================
' finding the last row in column AE
With ActiveSheet
lastrow = .Cells(.Rows.Count, "AE").End(xlUp).Row
End With
'========================================================
'making the no. column automated increasing no.
If IsNumeric(Range("AE" & lastrow)) = False Then
ActiveSheet.Cells(lastrow + 1, "AE").Value = ActiveSheet.Cells(lastrow + 1, "AE").Row - 23
Else
ActiveSheet.Cells(lastrow + 1, "AE").Value = ActiveSheet.Cells(lastrow, "AE").Value + 1
End If
'============================================================================================
ActiveSheet.Range("c13").Copy
rngFindValue.Offset(lastrow, 0).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.Range("c11").Copy
rngFindValue.Offset(lastrow, 1).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'===================================================================================================================
End Sub
with the code below i am trying to find a specific cell, offset it and paste from cell c11 and c13.
i've set the coloumn AE as the counter column (this part of the code works fine it finds the last row and add 1 to value of the previous.
but the paste part of the code keeps on pasting the values from c11 and c13 in row 45,
ie. the last row of AE will be row 3 but the pasting will still be on row 45
any help please.
Private Sub editprice_Click()
Dim rngFindValue As Range
Dim rngSearch As Range
Dim rngFind As Range
Dim lastrow As Long
On Error Resume Next
Application.ScreenUpdating = False
Set rngFind = ActiveSheet.Range("AD22:ZE22") 'search in this range of cells
Set rngSearch = rngFind.Cells(rngFind.Cells.Count) 'get the number of cells in this column
Set rngFindValue = rngFind.Find(Range("c9").Value, rngSearch, xlValues) 'search for the value that in cell c9
'================================================================================
' finding the last row in column AE
With ActiveSheet
lastrow = .Cells(.Rows.Count, "AE").End(xlUp).Row
End With
'========================================================
'making the no. column automated increasing no.
If IsNumeric(Range("AE" & lastrow)) = False Then
ActiveSheet.Cells(lastrow + 1, "AE").Value = ActiveSheet.Cells(lastrow + 1, "AE").Row - 23
Else
ActiveSheet.Cells(lastrow + 1, "AE").Value = ActiveSheet.Cells(lastrow, "AE").Value + 1
End If
'============================================================================================
ActiveSheet.Range("c13").Copy
rngFindValue.Offset(lastrow, 0).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.Range("c11").Copy
rngFindValue.Offset(lastrow, 1).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'===================================================================================================================
End Sub