#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Code Needed

Thank you in advance for all the help you have provided me in the past
and in advance for any help you can provide me now. I am working with
a macro to transfer data on an order form to another sheet. I am not
sure how to transfer all of the records there. Right now, I am only
able to transfer the first row. Can someone please help? I have the
code copied beneath.

Thank you....

Sub MoveDate()
' find the next available row on the sheet Data
Set rng = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp)(2)
With Worksheets("DayconOrder")
rng.Value = .Range("B3").Value
rng.Offset(0, 1).Value = .Range("B4").Value
rng.Offset(0, 2).Value = .Range("a12").Value
rng.Offset(0, 3).Value = .Range("B12").Value
rng.Offset(0, 4).Value = .Range("e12").Value
rng.Offset(0, 5).Value = .Range("f12").Value
rng.Offset(0, 6).Value = .Range("g12").Value
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code Needed

I sent you code in the workbook to do that? You didn't see it?

--
Regards,
Tom Ogilvy

"Carolyn" wrote in message
om...
Thank you in advance for all the help you have provided me in the past
and in advance for any help you can provide me now. I am working with
a macro to transfer data on an order form to another sheet. I am not
sure how to transfer all of the records there. Right now, I am only
able to transfer the first row. Can someone please help? I have the
code copied beneath.

Thank you....

Sub MoveDate()
' find the next available row on the sheet Data
Set rng = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp)(2)
With Worksheets("DayconOrder")
rng.Value = .Range("B3").Value
rng.Offset(0, 1).Value = .Range("B4").Value
rng.Offset(0, 2).Value = .Range("a12").Value
rng.Offset(0, 3).Value = .Range("B12").Value
rng.Offset(0, 4).Value = .Range("e12").Value
rng.Offset(0, 5).Value = .Range("f12").Value
rng.Offset(0, 6).Value = .Range("g12").Value
End With
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code Needed

Private Sub CommandButton1_Click()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
If Not IsEmpty(Me.Cells(13, 1)) Then
Set rng2 = Me.Range(Me.Cells(12, 1), Me.Cells(12, 1).End(xlDown))
ElseIf Not IsEmpty(Me.Cells(12, 1)) Then
Set rng2 = Me.Cells(12, 1)
Else
MsgBox "Nothing to do"
Exit Sub
End If
For Each cell In rng2
Set rng1 = Worksheets("Data1").Cells(Rows.Count, 1).End(xlUp)
rng1 = "Daycon"
rng1.Offset(0, 1) = Me.Range("B3")
rng1.Offset(0, 2) = Me.Range("B4")
rng1.Offset(0, 3) = Me.Range("B7")
rng1.Offset(0, 4) = cell
rng1.Offset(0, 5) = cell.Offset(0, 1)
rng1.Offset(0, 6) = cell.Offset(0, 4)
rng1.Offset(0, 7) = cell.Offset(0, 5)
rng1.Offset(0, 8) = cell.Offset(0, 6)
Next
End Sub

--
Regards,
Tom Ogilvy

"Carolyn" wrote in message
om...
Thank you in advance for all the help you have provided me in the past
and in advance for any help you can provide me now. I am working with
a macro to transfer data on an order form to another sheet. I am not
sure how to transfer all of the records there. Right now, I am only
able to transfer the first row. Can someone please help? I have the
code copied beneath.

Thank you....

Sub MoveDate()
' find the next available row on the sheet Data
Set rng = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp)(2)
With Worksheets("DayconOrder")
rng.Value = .Range("B3").Value
rng.Offset(0, 1).Value = .Range("B4").Value
rng.Offset(0, 2).Value = .Range("a12").Value
rng.Offset(0, 3).Value = .Range("B12").Value
rng.Offset(0, 4).Value = .Range("e12").Value
rng.Offset(0, 5).Value = .Range("f12").Value
rng.Offset(0, 6).Value = .Range("g12").Value
End With
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Code Needed

As always, thank you Tom. I am not sure what the problem is, but I
get a "Subscript out of range error" when I try to run the macro. Do
you have any idea why?

"Tom Ogilvy" wrote in message ...
Private Sub CommandButton1_Click()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
If Not IsEmpty(Me.Cells(13, 1)) Then
Set rng2 = Me.Range(Me.Cells(12, 1), Me.Cells(12, 1).End(xlDown))
ElseIf Not IsEmpty(Me.Cells(12, 1)) Then
Set rng2 = Me.Cells(12, 1)
Else
MsgBox "Nothing to do"
Exit Sub
End If
For Each cell In rng2
Set rng1 = Worksheets("Data1").Cells(Rows.Count, 1).End(xlUp)
rng1 = "Daycon"
rng1.Offset(0, 1) = Me.Range("B3")
rng1.Offset(0, 2) = Me.Range("B4")
rng1.Offset(0, 3) = Me.Range("B7")
rng1.Offset(0, 4) = cell
rng1.Offset(0, 5) = cell.Offset(0, 1)
rng1.Offset(0, 6) = cell.Offset(0, 4)
rng1.Offset(0, 7) = cell.Offset(0, 5)
rng1.Offset(0, 8) = cell.Offset(0, 6)
Next
End Sub

--
Regards,
Tom Ogilvy

"Carolyn" wrote in message
om...
Thank you in advance for all the help you have provided me in the past
and in advance for any help you can provide me now. I am working with
a macro to transfer data on an order form to another sheet. I am not
sure how to transfer all of the records there. Right now, I am only
able to transfer the first row. Can someone please help? I have the
code copied beneath.

Thank you....

Sub MoveDate()
' find the next available row on the sheet Data
Set rng = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp)(2)
With Worksheets("DayconOrder")
rng.Value = .Range("B3").Value
rng.Offset(0, 1).Value = .Range("B4").Value
rng.Offset(0, 2).Value = .Range("a12").Value
rng.Offset(0, 3).Value = .Range("B12").Value
rng.Offset(0, 4).Value = .Range("e12").Value
rng.Offset(0, 5).Value = .Range("f12").Value
rng.Offset(0, 6).Value = .Range("g12").Value
End With
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code Needed

If you ran this line

Set rng1 = Worksheets("Data1").Cells(Rows.Count, 1).End(xlUp)

and you don't have a sheet named Data1, then you would get that error. this
is just a guess however since,

a) you didn't say what macro you are running
b) you didn't say what line is highlighted when you get the error

Again, when I sent the workbook, I created a sheet named Data1 since the
code placed different data than you had in your Data sheet.


--
Regards,
Tom Ogilvy


"Carolyn" wrote in message
m...
As always, thank you Tom. I am not sure what the problem is, but I
get a "Subscript out of range error" when I try to run the macro. Do
you have any idea why?

"Tom Ogilvy" wrote in message

...
Private Sub CommandButton1_Click()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
If Not IsEmpty(Me.Cells(13, 1)) Then
Set rng2 = Me.Range(Me.Cells(12, 1), Me.Cells(12, 1).End(xlDown))
ElseIf Not IsEmpty(Me.Cells(12, 1)) Then
Set rng2 = Me.Cells(12, 1)
Else
MsgBox "Nothing to do"
Exit Sub
End If
For Each cell In rng2
Set rng1 = Worksheets("Data1").Cells(Rows.Count, 1).End(xlUp)
rng1 = "Daycon"
rng1.Offset(0, 1) = Me.Range("B3")
rng1.Offset(0, 2) = Me.Range("B4")
rng1.Offset(0, 3) = Me.Range("B7")
rng1.Offset(0, 4) = cell
rng1.Offset(0, 5) = cell.Offset(0, 1)
rng1.Offset(0, 6) = cell.Offset(0, 4)
rng1.Offset(0, 7) = cell.Offset(0, 5)
rng1.Offset(0, 8) = cell.Offset(0, 6)
Next
End Sub

--
Regards,
Tom Ogilvy

"Carolyn" wrote in message
om...
Thank you in advance for all the help you have provided me in the

past
and in advance for any help you can provide me now. I am working

with
a macro to transfer data on an order form to another sheet. I am

not
sure how to transfer all of the records there. Right now, I am only
able to transfer the first row. Can someone please help? I have

the
code copied beneath.

Thank you....

Sub MoveDate()
' find the next available row on the sheet Data
Set rng = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp)(2)
With Worksheets("DayconOrder")
rng.Value = .Range("B3").Value
rng.Offset(0, 1).Value = .Range("B4").Value
rng.Offset(0, 2).Value = .Range("a12").Value
rng.Offset(0, 3).Value = .Range("B12").Value
rng.Offset(0, 4).Value = .Range("e12").Value
rng.Offset(0, 5).Value = .Range("f12").Value
rng.Offset(0, 6).Value = .Range("g12").Value
End With
End Sub






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
VBA code needed ernie New Users to Excel 1 March 19th 10 12:45 PM
VBA code help needed Martin Excel Discussion (Misc queries) 3 April 28th 06 09:28 AM
VBA code Help needed liamothelegend Excel Programming 1 November 5th 03 12:25 PM
Fw:code needed ibo Excel Programming 2 August 5th 03 09:30 PM
code needed ibo Excel Programming 0 July 29th 03 05:32 PM


All times are GMT +1. The time now is 10:33 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"