PC Review


Reply
Thread Tools Rate Thread

check column -A- and fill out column -B- by vba

 
 
MicrosoftNews
Guest
Posts: n/a
 
      10th Feb 2008
Hi all,

please help me by solving the folowing problem...
I want to check a sheet with four columns
---------------------------------------------------
-A- -B- -C- -D-
123 active 1,2 3,0
456 hold 2,4 4,2
789 clear 5,7 3,6
123 3,9 2,4
123 1,7 8,4
789 9,4 4,3
456 4,3 2,8
---------------------------------------------------

now I want to check column -A- for "123"and fill the column -B- with the
value "active" for the following rows.

How can I do this by vba ?????

Many thx in advance.

greetings joachim


 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      10th Feb 2008
Sub surface()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To n
If Cells(i, 1).Value = 123 Then
Cells(i, 2).Value = "active"
End If
Next
End Sub
 
Reply With Quote
 
ilia
Guest
Posts: n/a
 
      10th Feb 2008
Try this. Insert the code below into a standard module of the
workbook you're working with. Replace the constants at the top to
suit your needs (I tried to make it more broad than you've outlined).
Hopefully it's self-explanatory.

Public Sub fillAdjacentColumn()
Const sheetName As String = "Sheet1"
Const columnToLookIn As String = "A:A"
Const lookFor As String = "123"
Const fillWith As String = "active"
Const columnsToTheRight As Integer = 1

Dim rngA As Excel.Range
Dim rng As Excel.Range
Dim wsh As Excel.Worksheet

Set wsh = ThisWorkbook.Worksheets(sheetName)

With wsh
Set rngA = Intersect( _
.Range(columnToLookIn), _
.UsedRange)
End With

For Each rng In rngA.Cells
If rng.Value = lookFor Then
rng.Offset(0, _
columnsToTheRight).Value = fillWith
End If
Next rng
End Sub


On Feb 10, 6:28*am, "MicrosoftNews" <Geschin...@gmx.de> wrote:
> Hi all,
>
> please help me by solving the folowing problem...
> I want to check a sheet with four columns
> ---------------------------------------------------
> -A- * * * *-B- * * * *-C- * * * *-D-
> 123 * * * *active * * * 1,2 * * * *3,0
> 456 * * * *hold * * * * 2,4 * * * *4,2
> 789 * * * *clear * * * * 5,7 * * * *3,6
> 123 * * * * * * * * * * * *3,9 * * * *2,4
> 123 * * * * * * * * * * * *1,7 * * * *8,4
> 789 * * * * * * * * * * * *9,4 * * * *4,3
> 456 * * * * * * * * * * * *4,3 * * * *2,8
> ---------------------------------------------------
>
> now I want to check column -A- for "123"and fill the column -B- with the
> value "active" for the following rows.
>
> How can I do this by vba ?????
>
> Many thx in advance.
>
> greetings joachim


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      10th Feb 2008
Do you also want the next 456 to receive "hold" in column B and the next 789 to
receive "clear" in column B.


Gord Dibben MS Excel MVP

On Sun, 10 Feb 2008 12:28:11 +0100, "MicrosoftNews" <(E-Mail Removed)> wrote:

>Hi all,
>
>please help me by solving the folowing problem...
>I want to check a sheet with four columns
>---------------------------------------------------
>-A- -B- -C- -D-
>123 active 1,2 3,0
>456 hold 2,4 4,2
>789 clear 5,7 3,6
>123 3,9 2,4
>123 1,7 8,4
>789 9,4 4,3
>456 4,3 2,8
>---------------------------------------------------
>
>now I want to check column -A- for "123"and fill the column -B- with the
>value "active" for the following rows.
>
>How can I do this by vba ?????
>
>Many thx in advance.
>
>greetings joachim
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically fill in third column depending on data in second column J.J. Microsoft Excel Programming 2 11th May 2007 07:34 PM
Fill a column with the contents of another column based on a choic =?Utf-8?B?U3Bhcmt5NTY=?= Microsoft Excel Misc 1 31st Mar 2007 04:18 AM
Auto Fill Column with Date based on rows in other column =?Utf-8?B?Sk9VSU9VSQ==?= Microsoft Excel Programming 2 6th Jun 2006 06:28 PM
What to do to fill column 2 with part of whats in column 1 Edwin Mashiringwani Microsoft Excel Misc 2 19th Nov 2005 03:57 PM
Fill handle - new column using a column and one cell =?Utf-8?B?TVM=?= Microsoft Excel Misc 4 2nd Nov 2005 11:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 PM.