Hello all,
I'm back here after a long time, once again seeking some support with another VBA macro! This time around, I have a query associated to converting numbers stored as text to regular numbers, where I am carrying this out across a couple different worksheets and I am working with a dynamic data range on each sheet.
At the moment, this is the VBA code I have:
In terms of what I am hoping to achieve, for each of the two worksheets mentioned above, I am firstly trying to find out the end point of my data, based on the last row in column "F" and "G" respectively. Secondly, I then wish to apply the format changes to specific ranges, starting at row "E2" and "F2" respectively and finishing at those 'end points'. I am currently finding however, that the code is only partially working, as it appears to be stopping before what I'd expect each end point to be, so not all of the data is converted to a regular number. Where the worksheet titled "Voyage Data Rec" has roughly 120 rows in this particular data set I am working with, the macro appears to be going to around line 60 only. With the worksheet titled "Sun Extract", where this has roughly 5000 rows, the macro is only going to around line 50 only.
I am unsure if the above is incorrectly written/missing important code in order to function as intended, or if the problem lies with something else in the overall code 'clashing' in some way. In the process of testing the above however, I have noticed that, where my entire macro usually runs from a separate sheet to those named above and 'fails', if I run the macro line by line with the worksheet "Voyage Data Rec" open, I get the result I intended for that particular sheet. As the above code is located at the very top of the entire macro, I am thinking this does indeed point to the above code being the problem. Furthermore, all the code after this seems to provide the expected result.
I hope this makes sense and should you require any further information, such as the entirety of the macro, then let me know and I am happy to provide.
Thanks in advance for any support you can provide and apologies if the issue is a glaringly obvious one - I'm still not the best with VBA!
I'm back here after a long time, once again seeking some support with another VBA macro! This time around, I have a query associated to converting numbers stored as text to regular numbers, where I am carrying this out across a couple different worksheets and I am working with a dynamic data range on each sheet.
At the moment, this is the VBA code I have:
VBA Code:
Dim ws2 As Worksheet
Set ws2 = ThisWorkbook.Sheets("Voyage Data Rec")
Dim ws3 As Worksheet
Set ws3 = ThisWorkbook.Sheets("Sun Extract")
With ws2.Range("E2:E" & Cells(Rows.Count, "F").End(xlUp).Row)
.NumberFormat = "General"
.Value = .Value
End With
With ws3.Range("F2:F" & Cells(Rows.Count, "G").End(xlUp).Row)
.NumberFormat = "General"
.Value = .Value
End With
In terms of what I am hoping to achieve, for each of the two worksheets mentioned above, I am firstly trying to find out the end point of my data, based on the last row in column "F" and "G" respectively. Secondly, I then wish to apply the format changes to specific ranges, starting at row "E2" and "F2" respectively and finishing at those 'end points'. I am currently finding however, that the code is only partially working, as it appears to be stopping before what I'd expect each end point to be, so not all of the data is converted to a regular number. Where the worksheet titled "Voyage Data Rec" has roughly 120 rows in this particular data set I am working with, the macro appears to be going to around line 60 only. With the worksheet titled "Sun Extract", where this has roughly 5000 rows, the macro is only going to around line 50 only.
I am unsure if the above is incorrectly written/missing important code in order to function as intended, or if the problem lies with something else in the overall code 'clashing' in some way. In the process of testing the above however, I have noticed that, where my entire macro usually runs from a separate sheet to those named above and 'fails', if I run the macro line by line with the worksheet "Voyage Data Rec" open, I get the result I intended for that particular sheet. As the above code is located at the very top of the entire macro, I am thinking this does indeed point to the above code being the problem. Furthermore, all the code after this seems to provide the expected result.
I hope this makes sense and should you require any further information, such as the entirety of the macro, then let me know and I am happy to provide.
Thanks in advance for any support you can provide and apologies if the issue is a glaringly obvious one - I'm still not the best with VBA!