ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Needed (https://www.excelbanter.com/excel-programming/301557-code-needed.html)

Carolyn[_3_]

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

Tom Ogilvy

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




Tom Ogilvy

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






Carolyn[_3_]

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




Tom Ogilvy

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






All times are GMT +1. The time now is 02:40 PM.

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