Hi all,
Long time reader, first time poster.
I am trying to implement a macro for a journal upload that has specific posting requirements. The VLookUp works as intended (returns the format of the journal entry - code below) but overrides any values that may have been entered after. Is it possible to have those lines skipped if the macro is run again? IE the end-user adds another GL after setting up their entry, the macro can be re-rerun and leave those cells with values as is.
Snip shows column E with the user input and column F after macro has been run with F12 updated. Desired output would be to have those cells remain intact and cells F13,17,18 etc. filled in if run again.
I have been Googling and saw a few of Floof's suggestions but I am not clever enough to modify them for my own needs since I'm still in the beginning stages of learning how to even write this!
Thank you for reading this and any help offered!!!!
Long time reader, first time poster.
I am trying to implement a macro for a journal upload that has specific posting requirements. The VLookUp works as intended (returns the format of the journal entry - code below) but overrides any values that may have been entered after. Is it possible to have those lines skipped if the macro is run again? IE the end-user adds another GL after setting up their entry, the macro can be re-rerun and leave those cells with values as is.
Snip shows column E with the user input and column F after macro has been run with F12 updated. Desired output would be to have those cells remain intact and cells F13,17,18 etc. filled in if run again.
I have been Googling and saw a few of Floof's suggestions but I am not clever enough to modify them for my own needs since I'm still in the beginning stages of learning how to even write this!
VBA Code:
Sub VLookUp()
Dim Sheet1Ws As Worksheet, ListWs As Worksheet
Dim ListLastRow As Long, Sheet1LastRow As Long, x As Long
Dim DataRng As Range
Set Sheet1Ws = ThisWorkbook.Worksheets("Sheet1")
Set ListWs = ThisWorkbook.Worksheets("List")
ListLastRow = ListWs.Range("A" & Rows.Count).End(xlUp).Row
Sheet1LastRow = Sheet1Ws.Range("A" & Rows.Count).End(xlUp).Row
Set DataRng = ListWs.Range("A2:H" & ListLastRow)
For x = 2 To Sheet1LastRow
On Error Resume Next
Sheet1Ws.Range("F" & x).Value = Application.WorksheetFunction.VLookUp( _
Sheet1Ws.Range("E" & x).Value, DataRng, 8, False)
Next x
End Sub
Thank you for reading this and any help offered!!!!