Overflow error in vba

imranfarooq

New Member
Joined
Jul 6, 2018
Messages
7
hi, guys can anyone please help me for this issue? i have 65000+ data i have already vba code with overflow error

i want to merge these type of data

from

A B
1 john mayer
2 calve
3 mitchele j
4 michel

to

A B
1 john mayer calve
2 mitchele j michel
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Welcome to the forum.

How would you like us to fix code that we cannot see? ;)

The most usual causes are:
1. You used an Integer variable for a row number. Integers only go up to 32767, so you should use Long instead.
2. You tried to use the Value property for a cell formatted as a date but with a large number in it (it would display in the sheet as ######)
 
Upvote 0
Code:
Sub DataMerger()
Dim col As Integer
Dim rw As Integer
Dim i As Integer
Dim j As Integer
Dim a As String
Dim b As String
Dim ws As Worksheet
For Each ws In Worksheets
col = ws.UsedRange.Columns.count
rw = ws.UsedRange.Rows.count
Dim col_num As Integer
col_num = 1
For j = 1 To col
For i = 2 To rw
      If ws.Cells(i, col_num) <> "" Then
         b = i
         a = ""
         a = ws.Cells(i, j)
      Else
      If ws.Cells(i, col_num) = "" Then
         a = a & " ^ " & ws.Cells(i, j)
         ws.Cells(i, j).ClearContents
         ws.Cells(b, j) = a
      End If
      End If
Next i
Next j
Next ws
End Sub

this is my code
 
Last edited by a moderator:
Upvote 0
Then your issue is the first one I mentioned. Change the Integer declarations to Long.
 
Upvote 0
Then why paste the old code? What error and on what line?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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