Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Insert Data Last Row Loop through cells Excel 2000 & 2003

Hello,

Sheet3 has data input Dates - B8:B15, Description - D8:D15, & Type -
E8:E16 I need the script to loop through these cells if there is data
in them to insert that data in Sheet2 next blank row.

The macro below will insert data for B8, D8, & E8 but will not for the
other cells that have data. So how can this macro be modified to loop
through Sheet3 cells B8:B15, D8:D15, & E8:E16 and insert the data in
Sheet2 next blank rows?

Sub FindBlankRowInsertData()
Dim lastrow As Object
Dim currentWorkbook As Workbook
Dim WS As Worksheet

With currentWorkbook
Set lastrow = Sheet2.Range("a65536").End(xlUp)
Set WS = Sheet3
'write the data to the new sheets
lastrow.Offset(1, 0) = WS.Range("D8:D15").Value
lastrow.Offset(1, 1) = WS.Range("B8:B15").Value
lastrow.Offset(1, 2) = WS.Range("E8:E15").Value
End With

End Sub

Thank you for your help,
jfcby

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Insert Data Last Row Loop through cells Excel 2000 & 2003

jfcby wrote:

'write the data to the new sheets
lastrow.Offset(1, 0) = WS.Range("D8:D15").Value
lastrow.Offset(1, 1) = WS.Range("B8:B15").Value
lastrow.Offset(1, 2) = WS.Range("E8:E15").Value


Replace this section with:

i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next


Nik
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Insert Data Last Row Loop through cells Excel 2000 & 2003

Hello Nik,

I have two questions:

1. Could you explain how this code works I learning VBA and I do not
understand how it works to make changes when needed?
i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next

2. When I put your modified code in the code below it puts the data in
the wrong place.

Sheet3 data is setup like so
B D
E
8 Dates Description Type
9 1/2/2006 New Years Day H
10 4/15/2006 Martin Luther King Day WH
11 8/21/2006 Memorial Day B
12 12/25/2006 Christmas Day O

Sheet2 data is setup like so
A2 B2 C2
Description Date Type

When I run your code it puts the description in column b in the last
row of data instead of the last blank row begining in column A. I would
like for sheet3 columnB data inserted in sheet2 columnB, sheet3 columnD
data inserted in sheet2 columnA, and sheet3 columnE data inserted in
sheet2 columnC.

This is the modified code:

Sub FindBlankRowInsertData2()
Dim lastrow As Object
Dim currentWorkbook As Workbook
Dim WS As Worksheet

With currentWorkbook
Set lastrow = Sheet2.Range("a65536").End(xlUp)
Set WS = Sheet3
'write the data to the new sheets
i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = WS.Range("B8").Offset(k, j - 1)
Next
i = i + 1
Next

End With

End Sub

Thank you for your help,
jfcby

Nik wrote:
jfcby wrote:

'write the data to the new sheets
lastrow.Offset(1, 0) = WS.Range("D8:D15").Value
lastrow.Offset(1, 1) = WS.Range("B8:B15").Value
lastrow.Offset(1, 2) = WS.Range("E8:E15").Value


Replace this section with:

i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next


Nik


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Insert Data Last Row Loop through cells Excel 2000 & 2003

Hello Nik,

I have two questions:

1. Could you explain how this code works I learning VBA and I do not
understand how it works to make changes when needed?
i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next

2. When I put your modified code in the code below it puts the data in
the wrong place.

Sheet3 data is setup like so
B D
E
8 Dates Description Type
9 1/2/2006 New Years Day H
10 4/15/2006 Martin Luther King Day WH
11 8/21/2006 Memorial Day B
12 12/25/2006 Christmas Day O

Sheet2 data is setup like so
A2 B2 C2
Description Date Type

When I run your code it puts the description in column b in the last
row of data instead of the last blank row begining in column A. I would
like for sheet3 columnB data inserted in sheet2 columnB, sheet3 columnD
data inserted in sheet2 columnA, and sheet3 columnE data inserted in
sheet2 columnC.

This is the modified code:

Sub FindBlankRowInsertData2()
Dim lastrow As Object
Dim currentWorkbook As Workbook
Dim WS As Worksheet

With currentWorkbook
Set lastrow = Sheet2.Range("a65536").End(xlUp)
Set WS = Sheet3
'write the data to the new sheets
i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = WS.Range("B8").Offset(k, j - 1)
Next
i = i + 1
Next

End With

End Sub

Thank you for your help,
jfcby

Nik wrote:
jfcby wrote:

'write the data to the new sheets
lastrow.Offset(1, 0) = WS.Range("D8:D15").Value
lastrow.Offset(1, 1) = WS.Range("B8:B15").Value
lastrow.Offset(1, 2) = WS.Range("E8:E15").Value


Replace this section with:

i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next


Nik


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Insert Data Last Row Loop through cells Excel 2000 & 2003

Hello Nik,

I have two questions:

1. Could you explain how this code works I learning VBA and I do not
understand how it works to make changes when needed?
i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next

2. When I put your modified code in the code below it puts the data in
the wrong place.

Sheet3 data is setup like so
B D
E
8 Dates Description Type
9 1/2/2006 New Years Day H
10 4/15/2006 Martin Luther King Day WH
11 8/21/2006 Memorial Day B
12 12/25/2006 Christmas Day O

Sheet2 data is setup like so
A2 B2 C2
Description Date Type

When I run your code it puts the description in column b in the last
row of data instead of the last blank row begining in column A. I would
like for sheet3 columnB data inserted in sheet2 columnB, sheet3 columnD
data inserted in sheet2 columnA, and sheet3 columnE data inserted in
sheet2 columnC.

This is the modified code:

Sub FindBlankRowInsertData2()
Dim lastrow As Object
Dim currentWorkbook As Workbook
Dim WS As Worksheet

With currentWorkbook
Set lastrow = Sheet2.Range("a65536").End(xlUp)
Set WS = Sheet3
'write the data to the new sheets
i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = WS.Range("B8").Offset(k, j - 1)
Next
i = i + 1
Next

End With

End Sub

Thank you for your help,
jfcby

Nik wrote:
jfcby wrote:

'write the data to the new sheets
lastrow.Offset(1, 0) = WS.Range("D8:D15").Value
lastrow.Offset(1, 1) = WS.Range("B8:B15").Value
lastrow.Offset(1, 2) = WS.Range("E8:E15").Value


Replace this section with:

i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next


Nik




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Insert Data Last Row Loop through cells Excel 2000 & 2003

Hello Nik,

I apologize for the multiple post but I got a error message when I
tried to post my message and did not relize my message posted anyway.
I'm sorry!

I kept working with the code and got it work. Thank you for your help!

Working Code:

Sub FindBlankRowInsertData2()
Dim lastrow As Object
Dim currentWorkbook As Workbook
Dim WS As Worksheet

With currentWorkbook
Set lastrow = Sheet2.Range("a65536").End(xlUp).Offset(1, 0)
Set WS = Sheet3
'write the data to the new sheets
i = 0
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = WS.Range("B8").Offset(k, j - 1)
Next
i = i + 1
Next
End With
End Sub

jfcby

Nik wrote:
jfcby wrote:

'write the data to the new sheets
lastrow.Offset(1, 0) = WS.Range("D8:D15").Value
lastrow.Offset(1, 1) = WS.Range("B8:B15").Value
lastrow.Offset(1, 2) = WS.Range("E8:E15").Value


Replace this section with:

i = 1
For Each j In Array(3, 1, 4)
For k = 0 To 7
lastrow.Offset(k, i) = ws.Range("b8").Offset(k, j - 1)
Next
i = i + 1
Next


Nik


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
insert rows in locked worksheet - from Excel 2003 to 2000 Venus Excel Discussion (Misc queries) 1 April 1st 09 05:59 PM
Excel 2003-Insert Cut Cells jo819 Setting up and Configuration of Excel 2 July 26th 08 12:36 AM
Delete row if all cells are blank, Excel 2000 & 2003 [email protected] Excel Discussion (Misc queries) 1 December 14th 07 03:55 PM
unlocked cells in excel 2000 now locked when opened in 2003 why? GallanH Excel Discussion (Misc queries) 4 August 31st 05 10:03 PM
In Excel 2000, Cannot edit cells in worksheet created in 2003? hbca4 Excel Discussion (Misc queries) 2 July 26th 05 06:21 PM


All times are GMT +1. The time now is 04:44 AM.

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

About Us

"It's about Microsoft Excel"