-
November 25th, 2013, 04:23 PM
#1
Assistance with coding
I'm attempting to create a vb type program via excel for my company. i took some classes but couldn't finish years due to work and $. i know my coding is incorrect but i cant seem to find the appropriote guides.
i'm trying to basicly create a calculator for parts of our inventory. some things were coming back to me as i was making my attempts but still cant seem to get it.
-
November 25th, 2013, 10:57 PM
#2
Re: Assistance with coding
Well you will need to ask a more direct question before anyone will be able to give you an answer.
Always use [code][/code] tags when posting code.
-
November 26th, 2013, 11:19 AM
#3
Re: Assistance with coding
my apologies basiclly i am counting wings. 8 piece, 14 piece and loose bags.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim smblorder As Single, bgblorder As Single, smtotal As Single, bgtotal As Single, bags As Single, Total As Single
smblorder = Cells(3, 4)
bgblorder = Cells(4, 4)
smtotal = Cells(3, 5)
bgtotal = Cells(4, 5)
smtotal = smblorder * 0.1111
bgtotal = bgblorder * 0.17
Cells(5, 5) = bags
End Sub
Option Explicit
Option Base 1
Private Sub codeAdd_Click()
Dim smtotal As Single, bgtotal As Single, bags As Single
Total = smtotal + bgtotal + bags
Cells(6, 5) = Total
End Sub
Option Explicit
Option Base 1
smtotal = smblorder * 0.1111
bgtotal = bgblorder * 0.17
End Sub
-
November 26th, 2013, 12:29 PM
#4
Re: Assistance with coding
I still don't see a question there
No idea what your variables are but I can tell you that in the Sub codeAdd your total will be 0 but it is also not dimmed so would result in an error first
None of the vars you are adding together have a value so in effect what you are doing is
Total=0+0+0
Cells(6,5)=0
The last part of code is missing the Sub definition
It also looks like this code is from more than one module
So again, you really need to ask a more direct question rather than having us try and guess what you need help with
Always use [code][/code] tags when posting code.
-
November 26th, 2013, 02:12 PM
#5
Re: Assistance with coding
again my aplolgies.
the first box beside 8 piece is how many orders are preped. i need to multply that by .1111 to make the box beside that say how much of a bag is prepped. same with the 14 piece. the box beside bags is how many loose bags i have and the total is the two totals (8 & 14 piece decimals) plus the bags. the grey areas i need to lock so they cant be manually changed. i cant remember the correct coding to make this work. I guess what i'm asking is what changes to i need to my coding for this to work correctly?
-
November 26th, 2013, 03:03 PM
#6
Re: Assistance with coding
Well you need to make references to these entries in your code in order to work with the values
I have never created a form in Excel so I am not sure what the syntax is for text boxes there in Vb the default name of a textbox is Text1 and you access its value using Text1.text It may be the same in Excel or it may be a bit different.
Your picture does not seem to jive with your description though
3*.1111 would not equal .2222 it would be .3333
2*.1111 would be .2222 not .34
0.2222+0.34+1 would not be .7322 it would be 1.5622
.3333+.2222+1 would be 1.5555
so I have no idea where those numbers come from
If it were VB then I would have 3 textboxes for examples sake I will use the default names of Text1 text2 and text3
I would use 3 labels for the output call them label1 label2 and label3 of course there would also be labels for the other text on the form
Code:
Label1.Caption=Text1.Text *.1111
Label2.Caption=Text2.Text *.1111
label3.caption=label1.caption+label2.caption+text3.text
now of course these really should be tested to make sure the entry is valid before processing and should be converted to a numeric var and the vars are what you should actually add but maybe that will get you pointed in the right direction
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|