Convert Range of Cells from 1's and 0's to text

mgradie

New Member
Joined
Nov 19, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I used a data collection tool that outputs the results in numbers which I need to convert to text. For example if the question has "yes" and "no" options, I have a series of 1's and 0's. So, I have a spreadsheet of 0 and 1's that I need to convert to text for readability. Sometimes I need to delete the value. Below is an example of what the data look like. I can write VBA code that will convert everything into Yes or No, but can't set it to distinguish the values. I thought it would be easy to find some VBA code but I can't. It seems easy enought but I keep getting sytax errors. Can anyone help me out?

1637362606855.png
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to Mr. Excel,

Distinguish the values?? What you've shown is only 1 and 0 to convert to, I assume, YES or NO text?!
 
Upvote 0
Welcome to Mr. Excel,

Distinguish the values?? What you've shown is only 1 and 0 to convert to, I assume, YES or NO text?!
Yes. I can change it to all No's or all Yes's, but I can't figure out how to say If the cell value is 0 then change it to No. If the cell value is 1 then change it to Yes. All the VBA I know I learned today. I figured I could find some code and adapt it But after spending most of the day, I turned to this board.
 
Upvote 0
Put these two lines of code inside your VBA procedure...

Columns("H").Replace 0, "No", xlWhole, , , , False, False
Columns("H").Replace 1, "Yes", xlWhole, , , , False, False
 
Upvote 0
Solution
Well, that worked. Thank you very much. I don't understand the syntax completely, but I think I can work with it.
 
Upvote 0

Forum statistics

Threads
1,215,773
Messages
6,126,822
Members
449,340
Latest member
hpm23

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