Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Converting Excel worksheets for Access

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Converting Excel worksheets for Access

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
i = 2
For Each cell In rng
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
i = i + 1
Next cell1
Next cell
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Converting Excel worksheets for Access

Sub ReorientData()
Dim sh as Worksheet, rng as Range
Dim sh1 as Worksheet, cell as Range
Dim rng1 as Range, rng2 as Range
Dim cell1 as Range, i as Long
set sh = activesheet
set rng = sh.Range(sh.Cells(2,1),sh.cells(2,1).End(xldown))
set sh1 = Worksheets.Add(after:=worksheets(worksheets.count) )
i = 2
for each cell in rng
set rng1 = sh.cells(cell.row,"IV").End(xltoLeft)
set rng2 = sh.range(cell.offset(0,2),rng1)
for each cell1 in rng2
sh1.cells(i,1) = cell.value
sh1.cells(i,2) = cell.offset(0,1)
sh1.cells(i,3) = cell1
i = i + 1
Next cell1
Next cell
end Sub

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Converting Excel worksheets for Access

Tom, you are brilliant - and quick! It appears to work perfectly except the
first row was deleted (on my worksheet the first row had only one account
number, if that makes a difference).

If I could understand your code (some of it I do) that would help me down
the road in case my worksheets are laid out differently.

Thank you so much for your help!!

David


"Tom Ogilvy" wrote:

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
i = 2
For Each cell In rng
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
i = i + 1
Next cell1
Next cell
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Converting Excel worksheets for Access

Your sample code appeared to represent a header row in row 1. So I started
in Row 2

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
' get the range of data using the same as if you clicked on A1,
' then held down the shift key while then hitting the end key and then hitting
' the down arrow key
' change to start in row 1
Set rng = sh.Range(sh.Cells(1, 1), sh.Cells(1, 1).End(xlDown))
' add a worksheet to place the data
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
' start recording the data in row 1 of the new sheet (change)
i = 1
For Each cell In rng
' find the right most column for this row (cell.row) that contains
' data - same as if you want to IV2 and hit End, then hit the left arrow
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
' define a range from the cell in the 3rd column to the cell
' in the leftmost column of that row and loop through them
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
' record the values in column 1, 2 and one of the
' data columns starting in column 3
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
' increment the row in the destination sheet
i = i + 1
Next cell1
Next cell
End Sub

--
Regards,
Tom Ogilvy




"David Vollmer" wrote:

Tom, you are brilliant - and quick! It appears to work perfectly except the
first row was deleted (on my worksheet the first row had only one account
number, if that makes a difference).

If I could understand your code (some of it I do) that would help me down
the road in case my worksheets are laid out differently.

Thank you so much for your help!!

David


"Tom Ogilvy" wrote:

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
i = 2
For Each cell In rng
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
i = i + 1
Next cell1
Next cell
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Converting Excel worksheets for Access

Thank you again, Tom. I will study this to try to understand it so that I can
change it for additional worksheets.

I have also been looking for a shortcut that would allow me to highlight
every row starting with the row I have selected down to the last possible row
in the sheet. The reason I want to do that is to delete rows that do not
contain any visible data but Excel thinks they do and includes those rows
(and columns) when entering Ctrl-End.

I would like to do the same thing with "empty" columns too.

David



"Tom Ogilvy" wrote:

Your sample code appeared to represent a header row in row 1. So I started
in Row 2

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
' get the range of data using the same as if you clicked on A1,
' then held down the shift key while then hitting the end key and then hitting
' the down arrow key
' change to start in row 1
Set rng = sh.Range(sh.Cells(1, 1), sh.Cells(1, 1).End(xlDown))
' add a worksheet to place the data
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
' start recording the data in row 1 of the new sheet (change)
i = 1
For Each cell In rng
' find the right most column for this row (cell.row) that contains
' data - same as if you want to IV2 and hit End, then hit the left arrow
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
' define a range from the cell in the 3rd column to the cell
' in the leftmost column of that row and loop through them
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
' record the values in column 1, 2 and one of the
' data columns starting in column 3
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
' increment the row in the destination sheet
i = i + 1
Next cell1
Next cell
End Sub

--
Regards,
Tom Ogilvy




"David Vollmer" wrote:

Tom, you are brilliant - and quick! It appears to work perfectly except the
first row was deleted (on my worksheet the first row had only one account
number, if that makes a difference).

If I could understand your code (some of it I do) that would help me down
the road in case my worksheets are laid out differently.

Thank you so much for your help!!

David


"Tom Ogilvy" wrote:

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
i = 2
For Each cell In rng
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
i = i + 1
Next cell1
Next cell
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Converting Excel worksheets for Access

There is no cost in deleting rows that do not actually exist, so you might as
well go all the way to the end:

Range(Activecell.Row & ":" & rows.count).EntireRow.Delete
activecell.Resize(,columns.count - activecell.Column + 1).EntireColumn.Delete

These should still work in xl2007
--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

Thank you again, Tom. I will study this to try to understand it so that I can
change it for additional worksheets.

I have also been looking for a shortcut that would allow me to highlight
every row starting with the row I have selected down to the last possible row
in the sheet. The reason I want to do that is to delete rows that do not
contain any visible data but Excel thinks they do and includes those rows
(and columns) when entering Ctrl-End.

I would like to do the same thing with "empty" columns too.

David



"Tom Ogilvy" wrote:

Your sample code appeared to represent a header row in row 1. So I started
in Row 2

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
' get the range of data using the same as if you clicked on A1,
' then held down the shift key while then hitting the end key and then hitting
' the down arrow key
' change to start in row 1
Set rng = sh.Range(sh.Cells(1, 1), sh.Cells(1, 1).End(xlDown))
' add a worksheet to place the data
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
' start recording the data in row 1 of the new sheet (change)
i = 1
For Each cell In rng
' find the right most column for this row (cell.row) that contains
' data - same as if you want to IV2 and hit End, then hit the left arrow
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
' define a range from the cell in the 3rd column to the cell
' in the leftmost column of that row and loop through them
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
' record the values in column 1, 2 and one of the
' data columns starting in column 3
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
' increment the row in the destination sheet
i = i + 1
Next cell1
Next cell
End Sub

--
Regards,
Tom Ogilvy




"David Vollmer" wrote:

Tom, you are brilliant - and quick! It appears to work perfectly except the
first row was deleted (on my worksheet the first row had only one account
number, if that makes a difference).

If I could understand your code (some of it I do) that would help me down
the road in case my worksheets are laid out differently.

Thank you so much for your help!!

David


"Tom Ogilvy" wrote:

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
i = 2
For Each cell In rng
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
i = i + 1
Next cell1
Next cell
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Converting Excel worksheets for Access

Thank you again, Tom. I almost forgot to use the File/SaveAs command and save
it under the same name, overwriting the original. That is the only way that
you can confirm that all "empty" rows and columns have been deleted.

"Tom Ogilvy" wrote:

There is no cost in deleting rows that do not actually exist, so you might as
well go all the way to the end:

Range(Activecell.Row & ":" & rows.count).EntireRow.Delete
activecell.Resize(,columns.count - activecell.Column + 1).EntireColumn.Delete

These should still work in xl2007
--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

Thank you again, Tom. I will study this to try to understand it so that I can
change it for additional worksheets.

I have also been looking for a shortcut that would allow me to highlight
every row starting with the row I have selected down to the last possible row
in the sheet. The reason I want to do that is to delete rows that do not
contain any visible data but Excel thinks they do and includes those rows
(and columns) when entering Ctrl-End.

I would like to do the same thing with "empty" columns too.

David



"Tom Ogilvy" wrote:

Your sample code appeared to represent a header row in row 1. So I started
in Row 2

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
' get the range of data using the same as if you clicked on A1,
' then held down the shift key while then hitting the end key and then hitting
' the down arrow key
' change to start in row 1
Set rng = sh.Range(sh.Cells(1, 1), sh.Cells(1, 1).End(xlDown))
' add a worksheet to place the data
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
' start recording the data in row 1 of the new sheet (change)
i = 1
For Each cell In rng
' find the right most column for this row (cell.row) that contains
' data - same as if you want to IV2 and hit End, then hit the left arrow
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
' define a range from the cell in the 3rd column to the cell
' in the leftmost column of that row and loop through them
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
' record the values in column 1, 2 and one of the
' data columns starting in column 3
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
' increment the row in the destination sheet
i = i + 1
Next cell1
Next cell
End Sub

--
Regards,
Tom Ogilvy




"David Vollmer" wrote:

Tom, you are brilliant - and quick! It appears to work perfectly except the
first row was deleted (on my worksheet the first row had only one account
number, if that makes a difference).

If I could understand your code (some of it I do) that would help me down
the road in case my worksheets are laid out differently.

Thank you so much for your help!!

David


"Tom Ogilvy" wrote:

Sub ReorientData()
Dim sh As Worksheet, rng As Range
Dim sh1 As Worksheet, cell As Range
Dim rng1 As Range, rng2 As Range
Dim cell1 As Range, i As Long
Set sh = ActiveSheet
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
i = 2
For Each cell In rng
Set rng1 = sh.Cells(cell.Row, "IV").End(xlToLeft)
Set rng2 = sh.Range(cell.Offset(0, 2), rng1)
For Each cell1 In rng2
sh1.Cells(i, 1) = cell.Value
sh1.Cells(i, 2) = cell.Offset(0, 1)
sh1.Cells(i, 3) = cell1
i = i + 1
Next cell1
Next cell
End Sub

worked for me.

--
Regards,
Tom Ogilvy


"David Vollmer" wrote:

I am needing to convert data from several workbooks so that I can import it
into Access. The worksheets are laid out similar to the following:

CustomerNumber # of Rows to add AccountNumbers
Original sheet

36798 3 158008 301976 897736 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383 320978


Completed sheet

36798 3 158008
36798 301976
36798 897736
36798 897728
37253 0 773751
37320 0 777838
37960 0 3770
38066 0 100216254
38562 1 91383
38562 320978

I can do all of this manually using the Insert rows, copy and paste special,
transpose, etc. commands but I will wear out my keyboard and fingers doing as
many records as I have and am going to have.

What I would like is a macro that will read the number of rows that need to
be inserted, copy the applicable account numbers, paste them using the paste
special, transpose, and then copy the customer number down the same number of
rows.

Deleting the "old" account numbers would be nice but I can easily do that by
deleting the columns later.

Some of the customers have 30, 40, 50, or more account numbers and I have
calculated the number of rows to enter in the second column.

Your help is appreciated as I am not very good at programming and learn (and
copy) a lot from searching this and other discussion groups.

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
Need help converting MS Access to Excel mustaine Excel Discussion (Misc queries) 3 March 28th 07 12:00 AM
Converting a Access routine into an Excel macro? turtle[_2_] Excel Discussion (Misc queries) 2 February 21st 07 06:38 PM
Converting Excel spreadsheet with formulae to Access database AndyL82 Excel Discussion (Misc queries) 1 February 3rd 07 06:53 PM
Converting Excel Worksheets into PDF Jonx[_2_] Excel Programming 5 August 17th 04 03:33 AM
Converting Access dll calls to Excel program Pal Excel Programming 1 February 1st 04 04:52 PM


All times are GMT +1. The time now is 11:45 AM.

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"