ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   resize and copy (https://www.excelbanter.com/excel-programming/350445-resize-copy.html)

jer

resize and copy
 
Dear all
I am trying to get from (an existing table)

Fees Frequency DueDate LDueDate PNoPayments
$50.00 Y 9/30/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4

to

Fees Frequency DueDate LDueDate PNoPayments
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4

with

Dim cell As Range, i As Long
Dim lastrow As Long, sh1 As Worksheet
Set sh1 = ActiveWorkbook.Worksheets("Sample")
lastrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row

For i = lastrow To 1 Step -1

Set cell = sh1.Cells(i, 1)

If cell.Offset(0, 4) 1 Then

cell.Resize(cell.Offset(0, 4) - 1, 1).EntireRow.Insert

cell.Resize(1, 5).Copy _
cell.Offset(1, 0).Resize(cell.Offset(0, 4) - 1, 5)

End If
Next i

but having trouble with last couple lines of the code, which I
have modified from newgroup contributors.

Any suggestions help would be greatly appreciated
--
thanks as always for the help

Tom Ogilvy

resize and copy
 
Dim cell As Range, i As Long
Dim lastrow As Long, sh1 As Worksheet
Set sh1 = ActiveWorkbook.Worksheets("Sample")
lastrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row

For i = lastrow To 1 Step -1

Set cell = sh1.Cells(i, 1)

If cell.Offset(0, 4) 1 Then

cell.Offset(1,0).Resize(cell.Offset(0, 4) - 1, 1).EntireRow.Insert

cell.Resize(1, 5).Copy _
cell.Offset(1, 0).Resize(cell.Offset(0, 4) - 1, 5)

End If
Next i

Untested, but I believe that will work.

--
Regards,
Tom Ogilvy



"jer" wrote in message
...
Dear all
I am trying to get from (an existing table)

Fees Frequency DueDate LDueDate PNoPayments
$50.00 Y 9/30/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4

to

Fees Frequency DueDate LDueDate PNoPayments
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4

with

Dim cell As Range, i As Long
Dim lastrow As Long, sh1 As Worksheet
Set sh1 = ActiveWorkbook.Worksheets("Sample")
lastrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row

For i = lastrow To 1 Step -1

Set cell = sh1.Cells(i, 1)

If cell.Offset(0, 4) 1 Then

cell.Resize(cell.Offset(0, 4) - 1, 1).EntireRow.Insert

cell.Resize(1, 5).Copy _
cell.Offset(1, 0).Resize(cell.Offset(0, 4) - 1, 5)

End If
Next i

but having trouble with last couple lines of the code, which I
have modified from newgroup contributors.

Any suggestions help would be greatly appreciated
--
thanks as always for the help




jer

resize and copy
 
Tom
Thank you ... works like a charm
--
thanks as always for the help


"Tom Ogilvy" wrote:

Dim cell As Range, i As Long
Dim lastrow As Long, sh1 As Worksheet
Set sh1 = ActiveWorkbook.Worksheets("Sample")
lastrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row

For i = lastrow To 1 Step -1

Set cell = sh1.Cells(i, 1)

If cell.Offset(0, 4) 1 Then

cell.Offset(1,0).Resize(cell.Offset(0, 4) - 1, 1).EntireRow.Insert

cell.Resize(1, 5).Copy _
cell.Offset(1, 0).Resize(cell.Offset(0, 4) - 1, 5)

End If
Next i

Untested, but I believe that will work.

--
Regards,
Tom Ogilvy



"jer" wrote in message
...
Dear all
I am trying to get from (an existing table)

Fees Frequency DueDate LDueDate PNoPayments
$50.00 Y 9/30/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4

to

Fees Frequency DueDate LDueDate PNoPayments
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$50.00 Y 9/30/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$150.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$200.00 Y 12/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4
$175.00 Y 1/31/2006 9/30/2011 4

with

Dim cell As Range, i As Long
Dim lastrow As Long, sh1 As Worksheet
Set sh1 = ActiveWorkbook.Worksheets("Sample")
lastrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row

For i = lastrow To 1 Step -1

Set cell = sh1.Cells(i, 1)

If cell.Offset(0, 4) 1 Then

cell.Resize(cell.Offset(0, 4) - 1, 1).EntireRow.Insert

cell.Resize(1, 5).Copy _
cell.Offset(1, 0).Resize(cell.Offset(0, 4) - 1, 5)

End If
Next i

but having trouble with last couple lines of the code, which I
have modified from newgroup contributors.

Any suggestions help would be greatly appreciated
--
thanks as always for the help






All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com