Hi all,
Having some issues with what I'm sure is a fairly easily solved issue. I am trying to create a brief form where a user is able to update three specific cells in another worksheet in my excel, based on the row defined by the user. The code as follows;
The problem is when I run the macro, nothing appears in the columns specified in the target worksheet. Any ideas!?
Thanks,
Olly
Having some issues with what I'm sure is a fairly easily solved issue. I am trying to create a brief form where a user is able to update three specific cells in another worksheet in my excel, based on the row defined by the user. The code as follows;
VBA Code:
Sub PO_Sent()
Dim shPO_Approve As Worksheet '[I]this is the worksheet the user is entering their data[/I]
Dim shPO_Database As Worksheet '[I]this is the worksheet the data should end up in[/I]
Dim PO_Number As String '[I]This is used to identify the relevant row in the target worksheet[/I]
Dim DocuSign_Ref As String '[I]This is the first piece of data to write to shPO_Database[/I]
Dim PO_DateSent As String '[I]This is the second piece of data to write to shPO_Database[/I]
Set shPO_Approve = ThisWorkbook.Sheets("PO Approval") [I]'Defining the data entry worksheet[/I]
Set shPO_Database = ThisWorkbook.Sheets("Purchase Orders") [I]'Defining the target worksheet[/I]
PO_Number = shPO_Approve.Range("D5")
DocuSign_Ref = shPO_Approve.Range("D7")
PO_DateSent = shPO_Approve.Range("D9")
lastrow = shPO_Database.Cells(Rows.Count, 1).End(xlUp).Row [I]'This is used to find the last row of data in the target worksheet[/I]
For i = 2 To lastrow [I]'to ignore the heading[/I]
If ThisWorkbook.Sheets("PO Approval").Cells(i, 6).Value = PO_Number Then [I]'the corresponding data is in column 6, this tells the if where to look[/I]
shPO_Database.Cells(i, 20).Value = PO_DateSent [I]'updates with the value in input worksheet, cell D9 to the target worksheet, column 20[/I]
shPO_Database.Cells(i, 21).Value = DocuSign_Ref [I]'updates with the value in input worksheet, cell D7 to the target worksheet, column 21[/I]
shPO_Database.Cells(i, 22).Value = Application.UserName [I]'Updates with the current user's user name in column 22[/I]
End If
Next
End Sub
The problem is when I run the macro, nothing appears in the columns specified in the target worksheet. Any ideas!?
Thanks,
Olly
Last edited by a moderator: