Jump to content
One on One Extensive Advanced Excel Training ×
Business Intelligence & Analytics for Digital Transformation

Tutorial 11 - Inputbox and MsgBox


Kashmira

Recommended Posts

Hi

I could do the assignment for this tutorial. Converting celsius to Fahrenheit.

I tried to add With Range and it gives me error, object require. Pls advise where my code is wrong.

Sub celcius()

Dim celcius As Integer
Dim Farenhiet As Integer


celcius = InputBox("Give me temperature in Celcius")

Range("B3").Value = celcius

Farenhiet = (celcius * 1.8) + 32

    With Range("B4").Value = Farenhiet

                .Font.Size = 11

                .Font.Color = "2367"
    
MsgBox "Farenhiet is" & " " & Farenhiet

End With

End Sub

Without using "With" it works. Do I need to use the Worksheets object. ?

Link to comment
Share on other sites

  • 1 year later...

1  Msgbok cannot be inside with and End with 

 

2  With has to be placed like this - all operations on B4

With Range("B4")

                 .Value = Farenhiet

                .Font.Size = 11

                .Font.Color = "2367"
    

End With

 

MsgBox "Farenhiet is" & " " & Farenhiet

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...