bfuchs
asked on
Need help in formatting excel cells
Hi Experts,
I have an Access file linked to an excel file for data comparison,
it compares rows from two sheets containing Social Securities, and displays in a report all names from sheetA that does not have matching records in SheetB and vice versa.
The problem I am encountering is that the data in excel file is not consistent, meaning the social is some time typed in with the dashes and some time it comes as numbers, and user changes it to display format as Social, however in Access it will only recognize the text rows while the numbers are shown as #Num!, what is the easiest solution?
I have an Access file linked to an excel file for data comparison,
it compares rows from two sheets containing Social Securities, and displays in a report all names from sheetA that does not have matching records in SheetB and vice versa.
The problem I am encountering is that the data in excel file is not consistent, meaning the social is some time typed in with the dashes and some time it comes as numbers, and user changes it to display format as Social, however in Access it will only recognize the text rows while the numbers are shown as #Num!, what is the easiest solution?
You can convert to text and replace dashes with somethign like this... If your social security number is in columns a then in columns B u can put this formula +SUBSTITUTE(TEXT(a1;);"-"; "")
ASKER
hi,
it gives me an error message,
besides how can I tell users to do that,
I really need an automation function on my program to perform that,
thanks,
Ben
it gives me an error message,
besides how can I tell users to do that,
I really need an automation function on my program to perform that,
thanks,
Ben
Could you pls post a sample Excel where you have the problem and will fix it for you ?
gowflow
gowflow
Ben,
Here is a macro that will convert social security numbers into text so it can be imported into Access. Install the macro in a regular module sheet, then select your data and run the macro.
As written, the macro assumes your data is in a single column. Text representations of social security numbers (where the hyphens were already typed in) will be left unchanged.
Cheers!
Brad
Here is a macro that will convert social security numbers into text so it can be imported into Access. Install the macro in a regular module sheet, then select your data and run the macro.
As written, the macro assumes your data is in a single column. Text representations of social security numbers (where the hyphens were already typed in) will be left unchanged.
Sub SSnumberToText()
Dim v As Variant
Dim rg As Range
Dim i As Long, n As Long
Set rg = Intersect(Selection, ActiveSheet.UsedRange)
v = rg.Value
n = rg.Rows.Count
For i = 1 To n
If v(i, 1) <> "" Then v(i, 1) = Format(v(i, 1), "000-00-0000;;;@")
Next
rg.Value = v
End Sub
Cheers!
Brad
ASKER
Hi Experts,
@gowflow,
attached is a sample of file.
@byundt,
Sorry for asking this, but I am not familiar with excel coding, is it possible to modify this so I can run it from Access, or perhaps you can give me exact steps how to install/run macros in Excel (2003)?
Also will the code work if there are additional columns besides the Social?
Thanks,
Ben
Book1.xls
@gowflow,
attached is a sample of file.
@byundt,
Sorry for asking this, but I am not familiar with excel coding, is it possible to modify this so I can run it from Access, or perhaps you can give me exact steps how to install/run macros in Excel (2003)?
Also will the code work if there are additional columns besides the Social?
Thanks,
Ben
Book1.xls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The original macro cares only about the first column of cells you select before running the macro. It leaves all other columns unchanged. The revised macro assumes the data is in column A of the first worksheet in the workbook; it assumes the data starts in cell A1 and continues until the last cell with data in column A.
To install the original macro in Excel 2003:
1. ALT + F11 to open the VBA Editor
2. Insert...Module to create an empty module sheet
3. Paste the code there
4. ALT + F11 to return to the worksheet
5. Save the file as either .xls or .xlsm file format
To run a macro in Excel:
1. ALT + F8 to display the macro selector
2. Choose the desired macro, then click the Run button
To change macro security so you can run macros in Excel 2003:
1. Open the Tools...Options...Security menu item
2. Click the button for Macro Security
3. Choose the option for "Medium. You can choose whether or not to run potentially unsafe macros."
When you open the workbook, you should get a warning message about macros. Make sure that you respond by telling Excel to Enable macros in that workbook.
To install the original macro in Excel 2003:
1. ALT + F11 to open the VBA Editor
2. Insert...Module to create an empty module sheet
3. Paste the code there
4. ALT + F11 to return to the worksheet
5. Save the file as either .xls or .xlsm file format
To run a macro in Excel:
1. ALT + F8 to display the macro selector
2. Choose the desired macro, then click the Run button
To change macro security so you can run macros in Excel 2003:
1. Open the Tools...Options...Security
2. Click the button for Macro Security
3. Choose the option for "Medium. You can choose whether or not to run potentially unsafe macros."
When you open the workbook, you should get a warning message about macros. Make sure that you respond by telling Excel to Enable macros in that workbook.
ASKER
Great Work,
Thank you!
Thank you!