Code wont transfer decimals, only whole numbers

wroze27

New Member
Joined
Apr 23, 2021
Messages
31
Office Version
  1. 2019
Platform
  1. Windows
Hey guys, below is some code I wrote for a friend and everything is working except for one minor flaw. The value from Sheet1.Range("B4") that gets added to where the Find function determines doesn't do decimals. The purpose of this macro is to make data entry easier for my coworker. Is there a formatting issue when pasting or when copying the data? I have formatted the cells themselves and they accept decimals from a manual input so the problem must lie somewhere in the coding.

Thanks a lot!

VBA Code:
Sub Sort_Function()
Dim Page As String
Page = Sheet1.Range("A4").Value
Dim Dono As Integer
Dono = Sheet1.Range("B4")
Dim Sun As String
Sun = Sheet1.Range("B1")

Sheets(Page).Select
ActiveSheet.Range("A1:B5").Find(What:=Sun).Offset(0, 1).Select
i = ActiveCell.Value
ActiveCell.Value = i + Dono

Sheet1.Range("B4").EntireRow.Delete

End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Change Integer to Double
 
Upvote 0
Solution
Change Integer to Double
I just now figured that out thanks. But I have a follow up question. I changed it to string and it also worked. Whats the difference between the setting it to string or double?
 
Upvote 0
Whilst it works this time, you should keep numbers as numbers, otherwise you could get into problems.
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

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