Issues with cell type conversion

TdotW

New Member
Joined
Feb 15, 2017
Messages
7
Hi, I'm having difficulty with excel's automatic recognition of cell formats.

I have a column imported from another source that are stored in 'general' format - numbers are stored as text, dates appear as 'dd/mm/yyyy.

I am assigning these values to another column in a separate sheet, however excel appears to automatically detect date data types incorrectly as mm/dd/yyyy.

This leads to issues with dates such 30/01/YYYY and therefore returns a numeric value.

Code:
Dim a
For irow = 4 To LastRow
    a = Cells(irow, 2).Value
        For icol = 3 To LastColumn
        If (Cells(irow, icol).Value > 0) Then
            Cells(irow, icol).Value = a
        End If
    Next icol
Next irow

'a' is the general variable, the cell it's assigned to has the auto-detection issue.

thanks for any help.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Are you able to import this column as Text? Then you can have better control over the data, and explicitly perform VBA code on it to do what you want.
 
Upvote 0

Forum statistics

Threads
1,215,786
Messages
6,126,891
Members
449,347
Latest member
Macro_learner

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