ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 857
- Office Version
- 365
- 2019
- Platform
- Windows
I am looking to modify my existing VBA to move data based off a cell's value. Currently I transfer assuming everything should go to the same destination column and copying over the dates. Little more simplistic (proved that code below)
But need to amend so the destination location may change based off the cell value.
For example if column F is ST then its respective amount and date go to its respective column. But if Column F is LT it goes to a different column F. Date 1 remains the same location of M. I use SPINV for other projects so i want to handle in VBA without adding helper columns.
This is SPINV
This is how it should look on my destination
But need to amend so the destination location may change based off the cell value.
For example if column F is ST then its respective amount and date go to its respective column. But if Column F is LT it goes to a different column F. Date 1 remains the same location of M. I use SPINV for other projects so i want to handle in VBA without adding helper columns.
VBA Code:
'ST amount
With wsSPINV
rws = .Range("G13:G13").End(xlDown).row - 1
wsDIVN.Range("D2").Resize(rws, 1).Value = .Range("G13").Resize(rws).Value
End With
'Date 1
With wsSPINV
rws = .Range("E13").End(xlDown).row - 1
wsDIVN.Range("M2").Resize(rws).Value = .Range("E13").Resize(rws).Value
wsDIVN.Range("M2").Resize(rws).TextToColumns Destination:=Range("M2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 5), TrailingMinusNumbers:=True
wsDIVN.Range("M2").Resize(rws).NumberFormat = "mm/dd/yyyy"
End With
This is SPINV
This is how it should look on my destination