255 Character Cell Limit From VBA Workaround?

eddiev1972

New Member
Joined
Mar 22, 2010
Messages
38
I am trying to pass a string from VBA excel to a cell on a worksheet and am encountering the 255 character limit that is truncating my string. I have found a workaround for some objects at Microsoft, but It does not seem to work on cells.

I was hoping someone could assist me with any suggestions.

When I try the below, string NoteString1 correctly appears in the cell, but NoteString2 does not appear at all.

Below is my current code

Code:
   NoteString1 = "Note 1 Here"  'actual note is over 200 characters
   NoteString2 = "Note 2 Here"  'actual note is over 100 characters
                    
   FirstNote = Len(NoteString1) + 1
                    
   Cells((i * Spacer + 6), 4).Characters(Start:=1).Text = NoteString1
   Cells((i * Spacer + 6), 4).Characters(Start:=FirstNote).Text= NoteString2

Thank you for any assistance.
 
Thank you! With Andrew Poulsom's additional information, I updated my code to the below, which seems to have worked.

Code:
Sheets("PAM").Select
Cells.Copy
Workbooks.Add
Cells.PasteSpecial xlPasteAll
Application.DisplayAlerts = False
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:=FileSaveName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
ActiveWindow.Close
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I was searching for days for a workaround for this, and this does exactly what I needed, thanks so much :)
 
Upvote 0

Hi Andrew,

Your link was top on my search for an answer for this in Google but I was wondering if there was a way to add this code into the "Worksheet" code module so that when a particular sheet is copied it activates automatically?

Or is it a case of assigning the code to a button like a macro and having a user execute it manually?

Any assistance greatly appreciated.

Mark.
 
Upvote 0
Sorry,

The code from Microsoft:

Code:
    Sub Test()

        'Turn off screen updating while the macro runs.
        Application.ScreenUpdating = False

        'xSheet is the sheet we want to copy.
        Set xSheet = ActiveSheet

        'Copy the worksheet to the destination you want. Cells with more
        'than 255 characters will be truncated by this step.
        xSheet.Copy Before:=Sheets(xSheet.Index)

        'ySheet is the new worksheet.
        Set ySheet = ActiveSheet

        'Copy all of the cells on the original worksheet...
        xSheet.Range("A:IV").Copy

        '...activate the new worksheet...
        ySheet.Range("A1").Select

        '...and paste the copied cells. All cells in the new worksheet
        'now have the correct contents.
        ySheet.Paste

        'Clear out the clipboard and select cell A1.
        Application.CutCopyMode = False
        Range("A1").Select

    End Sub

I assume is meant for a macro to be executed by a user when required?

Is there some way to tweak this code so that it could be added to the code for a particular worksheet (right-click worksheet and select View Code for the VBA window). When a user selects to copy the worksheet the code automatically kicks in, copies the sheet and then copies and pastes the values from the original worksheet to the new one?
 
Upvote 0
No worries but thank you for picking this up. I'll assign it to a button and work from there.

Thanks again Andrew.

Mark.
 
Upvote 0

Forum statistics

Threads
1,215,634
Messages
6,125,934
Members
449,275
Latest member
jacob_mcbride

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top