View Single Post
  #1   Report Post  
Klaasv Klaasv is offline
Junior Member
 
Posts: 1
Default Userrange to formula

Dear all,

I am new with the VBA part of Excel but I want to learn the language. Now I came up with the following problem. I want a pop upbox where the user can select a range and after pressing ok this should be converted to a formula in cell c1 (formula= "=sum(selected range)").

Now I have this:
Sub Test()

Set UserRange = Application.InputBox("Hallo", "Select your range:")
Rng = Application.WorksheetFunction.Sum(UserRange)
Range("C1").Select
Selection.Value = Rng

End Sub

After the popup it stops. Most likely because I misuse the Sum function but I couldn't find out a solution. Can someone help me?