There are many problems with your code.
Lets go through it line by line.
Code:
Dim r1, r2, r3 As Integer
Here you are telling Excel that you are going to be using r1, r2, and r3 as Variables which will hold integers. These cannot be used as references to a cell. They hold numbers directly. Also Integers are only whole numbers and their negatives. Your result is not an integer it is a Double, meaning a number with decimals. you should have this.
Code:
Dim r1 As Integer
Dim r2 as Double
you do not use r3 here so I left it out.
Code:
Set r1 = thisworksheet.Sheets("Sheet1").Cells(8, 4).Value
Here you are saying to put the "value" that is in Cell(8,4) into your variable called r1. There are 2 problems with how you wrote this.
1. You cannot use the Set command with a primitive data type like like an integer or a double. it can only be used with Objects.
2. it should be ThisWorkbook not thisworksheet
so it should look like this
Code:
r1 = ThisWorkbook.Sheets("Sheet1").Cells(8, 4).Value
The next line is completely useless.
Code:
Set r2 = thisworksheet.Sheets("Sheet1").Cells(9, 4).Value
Just like the line above it, this puts the "value" from cell(9,4) into r2. since we will be changing the value of r2 in the next line, there is no point in setting it here.
I believe you wanted to make it so that anything put into r2 would show up in cell(9,2) but this line does not do that.
Code:
r2.Value = r1.Value * 0.15
Here you want to make r2 equal to 15% of r1.
variables do not have a value atribute. They simply represent a number directly. It should look like this.
Finally you need to make Cell(9,4) show your result.
Code:
ThisWorkbook.Sheets("Sheet1").Cells(9, 4).Value = r2
So putting it all together it should look like this.
Code:
Sub SubmitDP()
Dim r1 As Integer
Dim r2 as Double
r1 = ThisWorkbook.Sheets("Sheet1").Cells(8, 4).Value
r2 = r1 * 0.15
ThisWorkbook.Sheets("Sheet1").Cells(9, 4).Value = r2
End Sub
This is not the best way to solve this problem. It works but I Think you intended to do something more like this.
Code:
Sub SubmitDP
Dim r1, r2 As Range
Set r1 = ThisWorkbook.Sheets("Sheet1").Range("H4")
Set r2 = ThisWorkbook.Sheets("Sheet1").Range("I4")
r2.Value = r1.Value * 0.15
End Sub
Here instead of making r1 and r2 numbers, I am making them range objects.
Next I can use the Set command so they become references to the ranges themselves.
Finally I can use the .Value atribute of the Ranges to set the values appropriately.
What a great way to kill my last hour of work.