I am trying to read a number from a Cell (this number changes so I have referenced the cell) and then copy it to a new sheet. There are no issues with the reading or copying. The issue I have is that the number that is being read from another cell doesn't work with decimal numbers. I can read cells with all whole numbers and copy their respective rows but just not decimals. I have tried a work around solution that rounded the numbers to whole numbers but later found this just wont work for the accuracy required in my solution.
A Snippet of code is below:
With ws.Result.Range ("A1:F" & .Cells(.Rows.Count, "F").End(xlUp).Row
.AutoFilter Field := 6, Criteria1 := wsResult.Range("J1") ' checks row F to see
whether the number in cell J1 matches any in row F
If Application.WorksheetFunction.Subtotal(103, .Columns(1)>1 Then .
Offset(1). Resize (.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy
Destination:= Main.Range("A22") ' Paste all rows starting at A22 on the main page.
I know the rest of the code works as planned its purely just being able to get the numbers that are decimal to work.
Any help would greatly be appreciated.
to get around any decimal formatting issue, you could try the following code (explanations in comments):
and should your actual cell content decimal separator be a dot (
.
), then be sure to substitute the comma (,
) decimal separator read from "J1" cell content with a dot by changing:to
as a side note, just be aware that
.Range("J1")
is pointing at the cell in the first row and 10th column of the referenced range. In this case your referenced range starts from cell "A1" of referencedwsResult
worksheet, so that is equivalent towsResult.Range("J1")
.