Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 40
Default How to check the whole column at the same time?

Hi all,

Could anyone help me how to check the column content by different condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in same
column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee

  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 735
Default How to check the whole column at the same time?

The simplest option for one-off changes is to use search and replace.
Select the entire column and use the search-replace function, three times.



--

Regards,
Nigel




"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee


  #3   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 245
Default How to check the whole column at the same time?

If you mean replace all instances of Father with 1; Mother with 2, Sister
with 3, try the following:


Option Base 1

Sub ChangeStrToNum()


Dim FindArr, ReplArr

FindArr = Array("Father", "Mother", "Sister")
ReplArr = Array(1, 2, 3)

'To undo
'ReplArr = Array("Father", "Mother", "Sister")
'FindArr = Array(1, 2, 3)

Range("yourRange").Activate 'change
If UBound(FindArr) = UBound(ReplArr) Then
For i = 1 To UBound(FindArr)

Selection.Replace What:=FindArr(i), Replacement:=ReplArr(i),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Next i
Else

MsgBox "Your arrays contain different numbers of elements"
End If
End Sub

--
Steve

"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee


  #4   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 245
Default How to check the whole column at the same time?

Please limit your question to one newsgroup

--
Steve

"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee


  #5   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 40
Default How to check the whole column at the same time?

Many thanks for your help.

How about if the string searching? such as "4~8¢J"

Thanks again!
Tlee




The simplest option for one-off changes is to use search and replace.
Select the entire column and use the search-replace function, three times.



--

Regards,
Nigel




"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee




  #6   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel
external usenet poster
 
Posts: 70
Default How to check the whole column at the same time?

Hi tlee,

try following code:-

Sub tlee()
Cells(1, 1).Select
a = "father"
b = "mother"
c = "sister"
While ActiveCell.Offset(1, 0).Value < "" Or ActiveCell.Value < ""
If ActiveCell.Value = a Then
ActiveCell.Value = 1
End If
If ActiveCell.Value = b Then
ActiveCell.Value = 2
End If
If ActiveCell.Value = c Then
ActiveCell.Value = 3
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub

'assumption = data is there in column A
--
Click on Yes, if it is useful.

Thanks & Best Regards,
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)


New Delhi, India


"Nigel" wrote:

The simplest option for one-off changes is to use search and replace.
Select the entire column and use the search-replace function, three times.



--

Regards,
Nigel




"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default How to check the whole column at the same time?

Hi Dilip,

Many thanks for your help. Let me test it.

tlee


Hi tlee,

try following code:-

Sub tlee()
Cells(1, 1).Select
a = "father"
b = "mother"
c = "sister"
While ActiveCell.Offset(1, 0).Value < "" Or ActiveCell.Value < ""
If ActiveCell.Value = a Then
ActiveCell.Value = 1
End If
If ActiveCell.Value = b Then
ActiveCell.Value = 2
End If
If ActiveCell.Value = c Then
ActiveCell.Value = 3
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub

'assumption = data is there in column A
--
Click on Yes, if it is useful.

Thanks & Best Regards,
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)


New Delhi, India


"Nigel" wrote:

The simplest option for one-off changes is to use search and replace.
Select the entire column and use the search-replace function, three
times.



--

Regards,
Nigel




"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the
same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in
the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default How to check the whole column at the same time?

Hi Steve,

Thanks for your help, let me try.

thanks
Tlee


If you mean replace all instances of Father with 1; Mother with 2, Sister
with 3, try the following:


Option Base 1

Sub ChangeStrToNum()


Dim FindArr, ReplArr

FindArr = Array("Father", "Mother", "Sister")
ReplArr = Array(1, 2, 3)

'To undo
'ReplArr = Array("Father", "Mother", "Sister")
'FindArr = Array(1, 2, 3)

Range("yourRange").Activate 'change
If UBound(FindArr) = UBound(ReplArr) Then
For i = 1 To UBound(FindArr)

Selection.Replace What:=FindArr(i), Replacement:=ReplArr(i),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Next i
Else

MsgBox "Your arrays contain different numbers of elements"
End If
End Sub

--
Steve

"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee


  #10   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default How to check the whole column at the same time?

You do have to watch out for wild cards (* and ?) and the escape character.

If you want to replace an asterisk character, use ~* in the from string.
If you want to replace a question mark, use ~? in the from string.
If you want to replace a tilde (~), use ~~ in the from string.



tlee wrote:

Many thanks for your help.

How about if the string searching? such as "4~8¢J"

Thanks again!
Tlee

The simplest option for one-off changes is to use search and replace.
Select the entire column and use the search-replace function, three times.



--

Regards,
Nigel




"tlee" wrote in message
...
Hi all,

Could anyone help me how to check the column content by different
condition?

If the content of the cell is "Father" then replace it to "1" in the same
column.
If the content of the other cell is "Mother" then replace it to "2" in
same column.
If the content of another cell is "Sister" then replace it to "3" in the
same column.

Besides, how can I implement this checking by using Marco?

Thanks,
Tlee



--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check the whole column at the same time? tlee Excel Worksheet Functions 7 April 28th 09 12:34 PM
Check if a time is past a certain time Savio Excel Discussion (Misc queries) 3 January 31st 09 10:21 PM
Loop through column(s) to check values, perform action based on check ward376 Excel Programming 4 November 6th 07 03:21 PM
how do I convert a date and time column to a time column thdorsky2 Excel Worksheet Functions 1 March 4th 05 08:49 PM


All times are GMT +1. The time now is 03:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"