diversification
New Member
- Joined
- Jun 24, 2020
- Messages
- 38
- Office Version
- 365
- Platform
- Windows
Hi there, I do a lot of Index Match type of stuff where I'm cross-referencing reports exported from multiple sources, and trying to match account numbers. Some of the account numbers are entirely numeric, while some are alphanumeric, so matching frequently breaks because of the way the data is exported. My solution has consistently been to import the data, then highlight the column containing the account numbers and use the Text To Columns feature, choosing delimited, deselecting all delimiters, and using General data format. The result is that the numeric account numbers store as numbers and the alphanumeric account numbers store as text. If I do this to all imports, it ensures that my Match functions work properly.
But... I'm getting tired of the extra clicks and want to do some automating. I'd like to put together VBA code that I can bind to a clickable button on the relevant sheets, which will execute the same type of conversion on the column in question. I use a lot of Tables, so ideally I'd like VBA that I can aim at either (1) a specific column, or (2) that I can aim at a specific Table column.
I'm VERY green writing VBA, but here's an example of code I use to clear a table before pasting in new data. I'm after something like this that I can bind to a key. I'm envisioning something similar where I'm basically just substituting in the Text To Columns (or other suggested code) in place of the ClearContents line.
But... I'm getting tired of the extra clicks and want to do some automating. I'd like to put together VBA code that I can bind to a clickable button on the relevant sheets, which will execute the same type of conversion on the column in question. I use a lot of Tables, so ideally I'd like VBA that I can aim at either (1) a specific column, or (2) that I can aim at a specific Table column.
I'm VERY green writing VBA, but here's an example of code I use to clear a table before pasting in new data. I'm after something like this that I can bind to a key. I'm envisioning something similar where I'm basically just substituting in the Text To Columns (or other suggested code) in place of the ClearContents line.
VBA Code:
Sub WipeSheet()
'
' WipeSheet Macro
' Wipes all entries in the sheet besides formulas
'
' Keyboard Shortcut: Ctrl+Shift+W
'
PopupPrompt = MsgBox("Do you want to clear this sheet?", vbYesNo + vbExclamation + vbDefaultButton2, "CLEAR SHEET DATA")
If PopupPrompt = vbNo Then
Exit Sub
End If
Range("AcctExportTable[Name]:AcctExportTable[Value]").ClearContents
Range("$A$10").Activate
End Sub