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)

Change Type (Action)Adjustment TypeAdjustment CodeTransaction TypeTransaction Usage CodeTransaction Type CodeTransaction NumberTransaction ContextSource Transaction DateLine IDDeal IDProduct FamilyPart #
ALMANUALRESTATE-SPVSSManualRB99999/30/2018CON-VSNT-TSS-SP-D
ALMANUALRESTATE-SPVSSManualRB99999/30/2018CON-VSNT-TSS-SP-D

<colgroup><col span="6"><col><col><col><col span="4"></colgroup><tbody>
</tbody>

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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,215,641
Messages
6,125,986
Members
449,276
Latest member
surendra75

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