Hi All,
First but definitely not my last contribution here! I am running into an issue with my macro where inconsistencies are appearing between various end-users. The issue falls in the pasting method; my macro starts off by pasting data from the clipboard into a new workbook and does some subsequent formatting from there. Various users are receiving error messages and incorrectly formatted data after running the macro from what I believe is due to various text-to-columns settings. I understand Excel tends to remember the previous text-to-column run when you paste data and implements these settings; would anyone be able to confirm if that is completely true?
To combat the issue, I added a new procedure that runs a mock text-to-columns with the Tab = True, which appears to sucessfully paste the data in the format that I see on my computer. Yet, this does not appear to be working for other users. Is there something I am overlooking? Does pasting data not take the settings from text-to-columns as I have assumed?
I appreciate any assistance.
See code below:
First but definitely not my last contribution here! I am running into an issue with my macro where inconsistencies are appearing between various end-users. The issue falls in the pasting method; my macro starts off by pasting data from the clipboard into a new workbook and does some subsequent formatting from there. Various users are receiving error messages and incorrectly formatted data after running the macro from what I believe is due to various text-to-columns settings. I understand Excel tends to remember the previous text-to-column run when you paste data and implements these settings; would anyone be able to confirm if that is completely true?
To combat the issue, I added a new procedure that runs a mock text-to-columns with the Tab = True, which appears to sucessfully paste the data in the format that I see on my computer. Yet, this does not appear to be working for other users. Is there something I am overlooking? Does pasting data not take the settings from text-to-columns as I have assumed?
I appreciate any assistance.
See code below:
Code:
Sub ClearTextToColumns()
On Error Resume Next
If IsEmpty(Range("A1")) Then Range("A1") = "XYZZY"
Range("A1").TextToColumns Destination:=Range("A1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=False, _
OtherChar:=""
If Range("A1") = "XYZZY" Then Range("A1") = ""
If Err.Number <> 0 Then MsgBox Err.Description
End Sub
Code:
Sub Reformatting()
'
' Reformatting Macro
'
' Keyboard Shortcut: Ctrl+Shift+X
'
' Do not copy Total Columns
Dim answer As Integer
answer = MsgBox("Did you copy the Total row?", vbYesNo + vbQuestion)
If answer = vbYes Then
MsgBox "Please do not copy Total row, this macro will fail if you do"
Exit Sub
Else
Application.ScreenUpdating = False
Dim wb As Workbook
Set wb = Workbooks.Add
' Reset text to columns
Call ClearTextToColumns
' Start Macro