why I am not to copy cells after blanks by using VBA code

Learning1

New Member
Joined
Aug 13, 2018
Messages
15
please see exmple below: when I ran my macro its only copy data up to Transection number and not all way to part number and I want all the columns in my break-up files.. I know I messing somewhere
and would appreciate the additional help. Thx a lot for your reply.

Set rng = cll.Resize(limit, cll.End(xlToRight).Column)



Set wrk = Application.Workbooks.Add
head.Copy wrk.Worksheets(1).Cells(1, 1)
rng.Copy wrk.Worksheets(1).Cells(2, 1)

[TABLE="width: 982"]
<colgroup><col span="6"><col><col><col><col span="4"></colgroup><tbody>[TR]
[TD]Change Type (Action)[/TD]
[TD]Adjustment Type[/TD]
[TD]Adjustment Code[/TD]
[TD]Transaction Type[/TD]
[TD]Transaction Usage Code[/TD]
[TD]Transaction Type Code[/TD]
[TD]Transaction Number[/TD]
[TD]Transaction Context[/TD]
[TD]Source Transaction Date[/TD]
[TD]Line ID[/TD]
[TD]Deal ID[/TD]
[TD]Product Family[/TD]
[TD]Part #[/TD]
[/TR]
[TR]
[TD]AL[/TD]
[TD]MANUAL[/TD]
[TD]RESTATE-SPVSS[/TD]
[TD]Manual[/TD]
[TD]R[/TD]
[TD]B[/TD]
[TD="align: right"]9999[/TD]
[TD][/TD]
[TD="align: right"]9/30/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]CON-VSNT-TSS-SP-D[/TD]
[/TR]
[TR]
[TD]AL[/TD]
[TD]MANUAL[/TD]
[TD]RESTATE-SPVSS[/TD]
[TD]Manual[/TD]
[TD]R[/TD]
[TD]B[/TD]
[TD="align: right"]9999[/TD]
[TD][/TD]
[TD="align: right"]9/30/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]CON-VSNT-TSS-SP-D[/TD]
[/TR]
</tbody>[/TABLE]

here is the code:

Sub doSplitRows()
Dim sht As Worksheet
Dim head As Range
Dim rng As Range
Dim limit As Integer
Dim cll As Range
Dim wrk As Workbook
Dim prefix As String
Dim i As Integer

Application.ScreenUpdating = False

'Workbook filename prefix
prefix = "test"

'Number of rows to create a new workbook
limit = 6000

Set sht = ActiveSheet
Set head = sht.Rows(1)
Set cll = sht.Cells(2, 1)
Do Until cll.Value = ""
i = i + 1
Set rng = cll.Resize(limit, cll.End(xlToRight).Column)


Set wrk = Application.Workbooks.Add
head.Copy wrk.Worksheets(1).Cells(1, 1)
rng.Copy wrk.Worksheets(1).Cells(2, 1)
wrk.SaveAs ThisWorkbook.Path & Application.PathSeparator & prefix & "_" & Format(i, "0000") 'Trying to make filename zero padded
wrk.Close
Set cll = cll.Offset(limit)
Loop

Application.ScreenUpdating = True

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I don't really know why you need to use resize but anyway try...
Code:
Set rng = cll.Resize(limit, Cells(cll.Row, Columns.count).End(xlToLeft).Column)
 
Last edited:
Upvote 0
I don't really know why you need to use resize but anyway try...
Code:
Set rng = cll.Resize(limit, Cells(cll.Row, Columns.count).End(xlToLeft).Column)


Hi Mark, My friend thank you so much for your prompt response.. It worked like piece of cake now.. once again thank you and because of people like you we could learn a thing or two..
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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