Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Kev427
 
Posts: n/a
Default Searching for data and inserting new rows

Hi
I have a spreadsheet from one of our clothing suppliers, which I am going to
import into our database for ordering. The format is:
Part No. / Description / Price / Size
The size is given as a range (i.e M-XL) for each item of clothing

What I want to do is analyse the size range and extract what sizes are
available, then insert new rows for each of these sizes
So, M-XL becomes:
Part No/ Description / Price / M
Part No / Description / Price / L
Part No / Description / Price / XL

I've got over 800 individual lines to do, so any help on automating this
task would be helpful!!

Thanks in advance
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

So each row becomes 4 (the existing and 3 more).

(I'm guessing that the existing row would already show S (small). Then you want
to add M,L,XL.)

If that's close:

Option Explicit
Sub testme01()

Dim wks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim myNewSizes As Variant
Dim TotalNewSizes As Long
Dim ColsToCopy As Long

Set wks = Worksheets("sheet1")

myNewSizes = Array("M", "L", "XL")
TotalNewSizes = UBound(myNewSizes) - LBound(myNewSizes) + 1

ColsToCopy = 3 'A:C

With wks
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
.Rows(iRow + 1).Resize(TotalNewSizes).EntireRow.Insert
.Cells(iRow + 1, "A").Resize(TotalNewSizes, ColsToCopy).Value _
= .Cells(iRow, "A").Resize(1, ColsToCopy).Value
.Cells(iRow + 1, ColsToCopy + 1).Resize(TotalNewSizes, 1).Value _
= Application.Transpose(myNewSizes)
Next iRow
End With

End Sub


Kev427 wrote:

Hi
I have a spreadsheet from one of our clothing suppliers, which I am going to
import into our database for ordering. The format is:
Part No. / Description / Price / Size
The size is given as a range (i.e M-XL) for each item of clothing

What I want to do is analyse the size range and extract what sizes are
available, then insert new rows for each of these sizes
So, M-XL becomes:
Part No/ Description / Price / M
Part No / Description / Price / L
Part No / Description / Price / XL

I've got over 800 individual lines to do, so any help on automating this
task would be helpful!!

Thanks in advance


--

Dave Peterson
  #3   Report Post  
kev427
 
Posts: n/a
Default

Thanks for your help, Dave. Greatly appreciated

"Dave Peterson" wrote:

So each row becomes 4 (the existing and 3 more).

(I'm guessing that the existing row would already show S (small). Then you want
to add M,L,XL.)

If that's close:

Option Explicit
Sub testme01()

Dim wks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim myNewSizes As Variant
Dim TotalNewSizes As Long
Dim ColsToCopy As Long

Set wks = Worksheets("sheet1")

myNewSizes = Array("M", "L", "XL")
TotalNewSizes = UBound(myNewSizes) - LBound(myNewSizes) + 1

ColsToCopy = 3 'A:C

With wks
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
.Rows(iRow + 1).Resize(TotalNewSizes).EntireRow.Insert
.Cells(iRow + 1, "A").Resize(TotalNewSizes, ColsToCopy).Value _
= .Cells(iRow, "A").Resize(1, ColsToCopy).Value
.Cells(iRow + 1, ColsToCopy + 1).Resize(TotalNewSizes, 1).Value _
= Application.Transpose(myNewSizes)
Next iRow
End With

End Sub


Kev427 wrote:

Hi
I have a spreadsheet from one of our clothing suppliers, which I am going to
import into our database for ordering. The format is:
Part No. / Description / Price / Size
The size is given as a range (i.e M-XL) for each item of clothing

What I want to do is analyse the size range and extract what sizes are
available, then insert new rows for each of these sizes
So, M-XL becomes:
Part No/ Description / Price / M
Part No / Description / Price / L
Part No / Description / Price / XL

I've got over 800 individual lines to do, so any help on automating this
task would be helpful!!

Thanks in advance


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Links & inserting rows into Excel - help? Angie H. New Users to Excel 1 January 26th 05 03:10 PM
inserting a row between two existing rows Jennie New Users to Excel 6 January 8th 05 01:48 PM
Inserting row but with formula carried down Steve R Excel Worksheet Functions 1 December 15th 04 03:23 PM
Inserting Multiple Rows with Formulas ShineboxNJ Excel Worksheet Functions 2 November 18th 04 02:30 AM
Inserting Blank Rows Macro? Michael Saffer Excel Worksheet Functions 2 November 9th 04 06:23 PM


All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"