Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Dispersing a value over multiple cells using a macro

The macro I've written, basically adds shipping to a parts ordered. I've got
the user form to locae a particular order number and add the shipping
accordingly, however, it only adds to the first value located, if i have
multiple parts listed under the same order number, it doesn't find them.
heres the macro as it stands now.

Private Sub cmdAdd_Click()
Dim Order As String
Dim Index As Variant
Dim nextrow As Long
Dim myRng As Range

Order = Me.txtOrder.Value

' Only looking in column K, so only look in column k
Set myRng = Range("k:k")

nextrow = Range("k65536").Row + 1

Index = Application.Match(CLng(Order), myRng, 0)

If IsError(Index) Then
MsgBox "Not Found, check Order No. and try again"
Else
myRng(Index).Select

ActiveCell.Offset(0, -9).Value = ActiveCell.Offset(0, -9).Value +
(Me.txtShip.Value / Me.txtPart.Value)
End If

Me.txtOrder.Value = ""
Me.txtShip.Value = ""
Me.txtPart.Value = ""
Me.txtOrder.SetFocus

End Sub

--
--Chip Smith--

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Dispersing a value over multiple cells using a macro

chip ,
Can you tell me few things...

1/ As I read this am I right in assuming you are looking in column K
for the order number then you from this you know wehre txtship.value
and txtPart value are are?

is it something like col K order, col L txtship.value etc?
I might be able to help you if I knew this.


Chip Smith wrote:
The macro I've written, basically adds shipping to a parts ordered. I've got
the user form to locae a particular order number and add the shipping
accordingly, however, it only adds to the first value located, if i have
multiple parts listed under the same order number, it doesn't find them.
heres the macro as it stands now.

Private Sub cmdAdd_Click()
Dim Order As String
Dim Index As Variant
Dim nextrow As Long
Dim myRng As Range

Order = Me.txtOrder.Value

' Only looking in column K, so only look in column k
Set myRng = Range("k:k")

nextrow = Range("k65536").Row + 1

Index = Application.Match(CLng(Order), myRng, 0)

If IsError(Index) Then
MsgBox "Not Found, check Order No. and try again"
Else
myRng(Index).Select

ActiveCell.Offset(0, -9).Value = ActiveCell.Offset(0, -9).Value +
(Me.txtShip.Value / Me.txtPart.Value)
End If

Me.txtOrder.Value = ""
Me.txtShip.Value = ""
Me.txtPart.Value = ""
Me.txtOrder.SetFocus

End Sub

--
--Chip Smith--


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Dispersing a value over multiple cells using a macro

yes i am searching in column k. i have a user form, where in the user puts in
the order number (txtorder.value), the number of parts (txtPart.value), and
shipping (txtShip.value). The macro then takes the shipping in USD and
divides it by the number of parts. After this, it is suppose to adjust the
price of the parts by adding the apporiate shipping. however when inputting
the order number, the macro only adjust the first part as opposed to the
others in the same order number below it.

i.e.

a b c d e f g h i j k
1 p $8.20 x x x x x x x x 234

2 r $9.00 x x x x x x x x 234

3 s $8.13 x x x x x x x x 234

4 t $4.11 x x x x x x x x 554

so the part in A1 is $8.20 on order number 234, the shipping for example
would add $1, which should also be added to the part in A2, and A3, however
it only does the part in A1...i don't know if that was confusing or
not...thanks!


--
--Chip Smith--



"stevebriz" wrote:

chip ,
Can you tell me few things...

1/ As I read this am I right in assuming you are looking in column K
for the order number then you from this you know wehre txtship.value
and txtPart value are are?

is it something like col K order, col L txtship.value etc?
I might be able to help you if I knew this.


Chip Smith wrote:
The macro I've written, basically adds shipping to a parts ordered. I've got
the user form to locae a particular order number and add the shipping
accordingly, however, it only adds to the first value located, if i have
multiple parts listed under the same order number, it doesn't find them.
heres the macro as it stands now.

Private Sub cmdAdd_Click()
Dim Order As String
Dim Index As Variant
Dim nextrow As Long
Dim myRng As Range

Order = Me.txtOrder.Value

' Only looking in column K, so only look in column k
Set myRng = Range("k:k")

nextrow = Range("k65536").Row + 1

Index = Application.Match(CLng(Order), myRng, 0)

If IsError(Index) Then
MsgBox "Not Found, check Order No. and try again"
Else
myRng(Index).Select

ActiveCell.Offset(0, -9).Value = ActiveCell.Offset(0, -9).Value +
(Me.txtShip.Value / Me.txtPart.Value)
End If

Me.txtOrder.Value = ""
Me.txtShip.Value = ""
Me.txtPart.Value = ""
Me.txtOrder.SetFocus

End Sub

--
--Chip Smith--



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Dispersing a value over multiple cells using a macro

try this out and see it works for you

Private Sub CommandButton1_Click()
Dim Order As String
Dim Index As Variant
Dim nextrow As Long
Order = txtorder.Value


With Worksheets(1).Range("K:K")
Set c = .Find(Order, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Cells(c.Row, 2).Value = Cells(c.Row, 2).Value +
(Me.txtShip.Value / Me.txtPart.Value)

Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Dispersing a value over multiple cells using a macro

thank you...that worked great!

--
--Chip Smith--



"stevebriz" wrote:

try this out and see it works for you

Private Sub CommandButton1_Click()
Dim Order As String
Dim Index As Variant
Dim nextrow As Long
Order = txtorder.Value


With Worksheets(1).Range("K:K")
Set c = .Find(Order, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Cells(c.Row, 2).Value = Cells(c.Row, 2).Value +
(Me.txtShip.Value / Me.txtPart.Value)

Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
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
editing multiple cells with a macro lacy Excel Discussion (Misc queries) 1 May 22nd 09 02:36 PM
how to make a macro to clear multiple cells from multiple worksheets? [email protected] Excel Worksheet Functions 2 October 18th 07 04:31 PM
macro copy/paste data from multiple cells to multiple cells Diana Excel Discussion (Misc queries) 0 July 10th 06 09:24 PM
Inputbox macro for multiple cells mcphc Excel Discussion (Misc queries) 2 June 23rd 06 12:06 PM
Recording macro for multiple cells SJC Excel Programming 2 July 20th 05 09:15 PM


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