![]() LastRow = Selection.Row + ' The final row in Selection (relative to start)įor Each c In Intersect(, Selection.Columns(1). Set groupedRange = Nothing ' The range which feeds outputText The following code should be more suitable - take particular note of FixBold(r,rs): Option Explicit Third pass sVal = "The quick brown XXXXFOXXXXX jumps over the lazy dog"įourth pass sVal = "The quick brown XXXXFOXXXXX jumps over the lazy dog" Second pass sVal = "The quick brown XXXXFOXXXXX jumps over the lazy dog" Initialisation sVal = "The quick brown XXXXFOXXXXX jumps over the lazy dog"įirst pass sVal = "The quick brown XXXXFOXXXXX jumps over the lazy dog" We will iterate through this to find out exactly what is going on. I will post improved code in an update in a separate answer if I get the chance, but I trust that this at least explains the overflow error. This aside, all that your code is presently doing is making each section bold, regardless of whether the corresponding cell is bold or not. This continues until k exceeds 32767, the upper limit for a signed 16-bit integer. Since there isn't one, it is assigned 0, from which i can be assigned to the first match all over again. However, j will be assigned to the next match. If i is currently at the last match of "XXXX" within sVal, j will be assigned to the position of the next match. To cut a long story short, your While condition checks to ensure that i is greater than zero, but i will switch between the occurrences of "XXXX" rather than reach zero. I had experimented with the following input and received an overflow after too long: I believe the overflow error is coming from "r.Characters(Start:=i - 2 * k * Len(strD), Length:=j - i - Len(strD)).Font.Bold = True" towards the bottom. R.Characters(Start:=i - 2 * k * Len(strD), Length:=j - i - Len(strD)).Font.Bold = True SVal = Replace(r.Value, strD & " " & strD, " ") First one imports the data and then the second macro does a small analysis of the imported data on a seperate sheet. When I run them individually, it is fine, but when I call them one after the other, I get an error. Im getting an overflow error when I call my macros. OutputText = outputText & " " & IIf(c.Font.Bold, strDelim, "") & c.Value & IIf(c.Font.Bold, strDelim, "") Excel VBA: Overflow error (2 answers) Closed 4 years ago. OutputText = IIf(c.Font.Bold, strDelim, "") & c.Value & IIf(c.Font.Bold, strDelim, "") ![]() If c.Borders(xlEdgeTop).LineStyle xlNone Then I added the second part to the macro, and for some reason I'm getting an overflow. It was working fine until I realized it didn't account for the properties of the text (specifically the bold font). That leaves the Source worksheet name or index (in my solution referred as srcID) as the only unclarified variable.It is important because if you save one or more of the Source workbooks with another than the expected worksheet active, your code may (will) fail. I have a macro that combines cells in a range based on their borders. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |