Include Several Line in MsgBox

xeeshanxp

New Member
Joined
Jun 22, 2010
Messages
25
Hi

Thankyou for your support

1) Can you please tell me how do i include several lines in msgbox
Right know I have only one line i want to add two line Pitch Diamater & Radius.
2) How do i bring all the data values in excel sheet1 I know we have to use Dim ws As Worksheet but still not working
3) I want to add another button which quickly clears all the value

Thanks in Advance




MsgBox "Pitch Circumfarance is " & pcirc
Private Sub CommandButton1_Click()
Dim pitch As Variant
Dim teeth As Variant
Dim pcirc As Variant
Dim smotor As Variant
Dim drivm As Variant
Dim revsh As Variant
Dim steprev As Variant
Dim ldis As Variant
Dim perr As Variant
Dim nerr As Variant
Dim dist As Variant
Dim ecal As Variant
Dim nst As Variant
Dim finalst As Variant
smotor = Me.smotor.Value
drivm = Me.drivm.Value
revsh = smotor * drivm
pitch = Me.pitch.Value
teeth = Me.teeth.Value
pcirc = pitch * teeth
steprev = revsh / pcirc
dist = Me.dist.Value
perr = Me.perr.Value
nerr = Me.nerr.Value
ldis = dist * steprev
ecal = steprev * perr
nst = ldis - ecal
finalst = nst / dist
MsgBox "Pitch Circumfarance is " & pcirc
MsgBox revsh
MsgBox steprev
MsgBox finalst
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try like this

Code:
MsgBox "Pitch Circumfarance is " & pcirc & vbnewline & "Radius is " & 'whatever your variable for radius is
 
Upvote 0
excellent what should i do so it should delete the old value
I have to use a loop

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet3")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

code like this
 
Upvote 0
I don't understand what you mean. If you write a value to a cell that will overwrite the old values.

To clear a range of cells

Code:
Range("A1:E2").ClearContents
 
Upvote 0
Sorry I mean each time we do the calculation we can record those value in the excel sheet
so it will be look like this.. bit like a data base
PCIRC Radius
15 10
20 13
30
40
 
Upvote 0
Try like this

Code:
With Sheets("Sheet3")
    .Range("A" & Rows.Count).End(xlUp).Offset(1).Value = pcirc
End With
 
Upvote 0
For cc = 2 To 10

Range("b" & cc).Value = smotor
Range("c" & cc).Value = drivm
Range("d" & cc).Value = pitch
Range("e" & cc).Value = teeth
Range("f" & cc).Value = pcirc
Range("g" & cc).Value = steprev
Range("h" & cc).Value = dist
Range("i" & cc).Value = perr
Range("j" & cc).Value = finalst
cc = cc + 1
Next cc

I want next cc will only run when command button press again any sugesstion if i put Next cc between if then loop
to put the check
 
Upvote 0
Maybe like this (no loop)

Code:
cc = Range("B" & Rows.Count).End(xlUp).Row + 1
Range("b" & cc).Value = smotor
Range("c" & cc).Value = drivm
Range("d" & cc).Value = pitch
Range("e" & cc).Value = teeth
Range("f" & cc).Value = pcirc
Range("g" & cc).Value = steprev
Range("h" & cc).Value = dist
Range("i" & cc).Value = perr
Range("j" & cc).Value = finalst
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top