Thecraftycarrot
New Member
- Joined
- Nov 8, 2018
- Messages
- 27
Hi All, i am trying to copy a cell to columns to the right.
The below code is relating to an if yes statement, that if criteria is met, it will find the the required cell and update it (successfully works)
However i need to tweek the above formula, instead of the updating the found cell i.e. Sheets("sheet2").Cells(updateRow, updateCol).Value - i need to copy and paste/offset this into a cell on the same row but two columns to the right.
i would imagine the code for updateValue will need to be something like this (but really have no idea how to get this to work):
The below code is relating to an if yes statement, that if criteria is met, it will find the the required cell and update it (successfully works)
Code:
Dim checkCell As Range
Dim cell As Range
Dim endRow As Long
Dim updateRow As Long
Dim updateCol As Long
Dim colName As String
Dim updateValue As String
Set checkCell = Sheets("Sheet 1 ").Range("G45")
If checkCell.Value = "Yes" Then
rowName = Sheets("Sheet1").Range("M45").Value
updateRow = Sheets("sheet2").Range("A4:a1000").Find(rowName, LookIn:=xlValues).Row
colName = "Persons name"
updateCol = Sheets("sheet2").Range("A3:AZ3").Find(colName, LookIn:=xlValues).Column
updateValue = Sheets("Sheet1").Range("E6").Value
Sheets("sheet2").Cells(updateRow, updateCol).Value = updateValue
However i need to tweek the above formula, instead of the updating the found cell i.e. Sheets("sheet2").Cells(updateRow, updateCol).Value - i need to copy and paste/offset this into a cell on the same row but two columns to the right.
i would imagine the code for updateValue will need to be something like this (but really have no idea how to get this to work):
Code:
updateValue = Sheets("sheet2").Cells(updateRow, updateCol).Value.offset(0,2)