Type mismatch error which I dont understand

Heerser

New Member
Joined
Oct 25, 2018
Messages
5
Sub Transpose()
Dim ws As Worksheet
Dim icol As Long
Dim irow As Long
Dim a As Integer
Dim niterations As Integer
Dim number As Integer

Set ws = Sheets("Sheet1")
icol = ws.Columns.Count
irow = ws.Columns.Count
N = 2500
niterations = (irow / N)

For i = 1 To niterations
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = i
ws.Cells("((i-1)*N+1)):(i*N+1)", 1).Copy
Sheets(i).Cells(1, 1).PasteSpecial Transpose:=True
Next


End Sub

I keep getting a type mismatch error, anyone has any idea why?
 

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.
Code:
Sub Transpose()
 'Dim lr As Long
 Dim ws As Worksheet
 'Dim vcol, i As Integer
 Dim icol As Long
 Dim irow As Long
 Dim a As Integer
 Dim niterations As Integer
 Dim number As Integer
 
 'Dim myarr As Variant
 'Dim cola As String
 'Dim titlerow As Integer
 'vcol = 3
   Set ws = Sheets(1)
 'lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
 'title = "A1:CY1"
 'titlerow = ws.Range(title).Cells(1).Row
 'icol = ws.Columns.Count
 icol = ws.Columns.Count
 irow = ws.Columns.Count
 N = 2500
 niterations = (irow / N)
 
 For i = 1 To niterations
 Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = i
 ws.Cells("((i-1)*N+1)):(i*N+1)", 1).Copy
 Sheets(i).Cells(1, 1).PasteSpecial Transpose:=True
 Next
 
 
End Sub
 
Upvote 0
No definitely not, thanks! but it doesn't solve the mismatch error. Would have been a problem for after this problem though, ones again thanks!
 
Upvote 0
I keep getting a type mismatch error, anyone has any idea why?
When you are asking about an error, it is always a good idea to state which line is causing the error as well as giving an outline of what the code is trying to do, particularly at the point of the error.

However, it appears the error would be at this line
ws.Cells("((i-1)*N+1)):(i*N+1)", 1).Copy

I presume that you are trying to calculate some range of cells to copy, based on the values of i and N but I don't know what you are trying to do. The syntax in that line is completely mixed up.
In any case because that blue text is enclosed by quotes, it is being treated as a literal string and no calculation will be made.
Further, there is a mismatch in the number of opening & closing parentheses in that line of code so that will also need attention.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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