I have numeric values on specific cells, the cell's row and column are known. I want to assign the numeric values in these cells to an integer variable in my code that I could then modify and use to update the same cell.
I have tried using the following codes but they did not work because when I add my variables to watch, the value of my variables remained as 0 even the cells have non zero numbers.
Dim GetTableCount as Integer
GetTableCount = Cells(17, 13).value
GetTableCount = CInt(Cells(17, 13).value)
GetTableCount = Range(M17)
GetTableCount = Range(M17).value
GetTableCount = CInt(Range(M17).value)
GetTableCount = CInt(Range(M17))
I have also tried using the index function but I failed on looking up the right syntax. My last attempt to solve the problem is to specify the cells to "Numbers" format instead of "General" but still nothing.
It turns out that
anyintvar = Cells(row, column)
works but the code is reading it from a different worksheet so the value remains at 0, with the cell from wherever sheet the code is reading seems to be empty.
Even though I had these lines for sheet selections
Sheets("ADMIN").Visible = True
Sheets("ADMIN").Select
the code still does not read from the selected sheet.
Using this however:
GetTableCount = ActiveWorkbook.Worksheets("ADMIN").Cells(rownumber, columnnumber)
fixed the problem. I did not even have to write the pervious two lines anymore. Kudos to @jpinto3912 Page where I found the solution
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.