PC Review


Reply
Thread Tools Rate Thread

Changing Value using vba

 
 
Greg B
Guest
Posts: n/a
 
      9th Jul 2009
Here is a copy of the code i want to use and adapt but I am a little stuck.
Dim rng As Range, cell As Range, col As Long
Dim rw As Long
col = 6
rw = 1
With Worksheets("STOCKLIST")
Set rng = .Range(.Cells(2, col), .Cells(Rows.Count, col).End(xlUp))
End With
For Each cell In rng
If UCase(cell.Value) = "YES" Then
cell.EntireRow.Copy Destination:=Worksheets("interM") _
.Cells(rw, 1)
rw = rw + 1
End If

I would like to have the macro look for the matching code which is "YES"
situated anywhere in column F, when it finds it I would like it to add 1
value to the number in column e on the same row? I mean this

alpha a 0 YES
to
alpha a 1 YES
Sorry about the bad example.

Thank you
Greg B


 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      9th Jul 2009

Sub ClearColumns()
Dim rng As Range, cell As Range, col As Long
Dim rw As Long
col = 6
rw = 1
With Worksheets("STOCKLIST")
Set rng = .Range(.Cells(2, col), .Cells(Rows.Count, col).End(xlUp))
End With
For Each cell In rng
If UCase(cell.Value) = "YES" Then
cell.EntireRow.Copy Destination:=Worksheets("interM") _
.Cells(rw, 1)
Worksheets("STOCKLIST").Range("E" & cell.Row) = _
Worksheets("STOCKLIST").Range("E" & cell.Row) + 1
rw = rw + 1
End If
Next
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Greg B" wrote:

> Here is a copy of the code i want to use and adapt but I am a little stuck.
> Dim rng As Range, cell As Range, col As Long
> Dim rw As Long
> col = 6
> rw = 1
> With Worksheets("STOCKLIST")
> Set rng = .Range(.Cells(2, col), .Cells(Rows.Count, col).End(xlUp))
> End With
> For Each cell In rng
> If UCase(cell.Value) = "YES" Then
> cell.EntireRow.Copy Destination:=Worksheets("interM") _
> .Cells(rw, 1)
> rw = rw + 1
> End If
>
> I would like to have the macro look for the matching code which is "YES"
> situated anywhere in column F, when it finds it I would like it to add 1
> value to the number in column e on the same row? I mean this
>
> alpha a 0 YES
> to
> alpha a 1 YES
> Sorry about the bad example.
>
> Thank you
> Greg B
>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      9th Jul 2009

Maybe
sub addonetocoleifcolfisyes()
for each c in rng
if ucase(c)="YES" Then c.offset(,-1)= _
c.offset(,-1)+1
next

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Greg B" <iwccweb(nospam)@ihug.com.au> wrote in message
news:5B7D38C4-5EA7-48AE-A33B-(E-Mail Removed)...
> Here is a copy of the code i want to use and adapt but I am a little
> stuck.
> Dim rng As Range, cell As Range, col As Long
> Dim rw As Long
> col = 6
> rw = 1
> With Worksheets("STOCKLIST")
> Set rng = .Range(.Cells(2, col), .Cells(Rows.Count, col).End(xlUp))
> End With
> For Each cell In rng
> If UCase(cell.Value) = "YES" Then
> cell.EntireRow.Copy Destination:=Worksheets("interM") _
> .Cells(rw, 1)
> rw = rw + 1
> End If
>
> I would like to have the macro look for the matching code which is "YES"
> situated anywhere in column F, when it finds it I would like it to add 1
> value to the number in column e on the same row? I mean this
>
> alpha a 0 YES
> to
> alpha a 1 YES
> Sorry about the bad example.
>
> Thank you
> Greg B
>
>


 
Reply With Quote
 
Greg B
Guest
Posts: n/a
 
      9th Jul 2009

Thank you Jacob it works perfectly
Greg B

"Jacob Skaria" <(E-Mail Removed)> wrote in message
news:371F3CB3-52C7-4020-A3EE-(E-Mail Removed)...
> Sub ClearColumns()
> Dim rng As Range, cell As Range, col As Long
> Dim rw As Long
> col = 6
> rw = 1
> With Worksheets("STOCKLIST")
> Set rng = .Range(.Cells(2, col), .Cells(Rows.Count, col).End(xlUp))
> End With
> For Each cell In rng
> If UCase(cell.Value) = "YES" Then
> cell.EntireRow.Copy Destination:=Worksheets("interM") _
> .Cells(rw, 1)
> Worksheets("STOCKLIST").Range("E" & cell.Row) = _
> Worksheets("STOCKLIST").Range("E" & cell.Row) + 1
> rw = rw + 1
> End If
> Next
> End Sub
>
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Greg B" wrote:
>
>> Here is a copy of the code i want to use and adapt but I am a little
>> stuck.
>> Dim rng As Range, cell As Range, col As Long
>> Dim rw As Long
>> col = 6
>> rw = 1
>> With Worksheets("STOCKLIST")
>> Set rng = .Range(.Cells(2, col), .Cells(Rows.Count, col).End(xlUp))
>> End With
>> For Each cell In rng
>> If UCase(cell.Value) = "YES" Then
>> cell.EntireRow.Copy Destination:=Worksheets("interM") _
>> .Cells(rw, 1)
>> rw = rw + 1
>> End If
>>
>> I would like to have the macro look for the matching code which is "YES"
>> situated anywhere in column F, when it finds it I would like it to add 1
>> value to the number in column e on the same row? I mean this
>>
>> alpha a 0 YES
>> to
>> alpha a 1 YES
>> Sorry about the bad example.
>>
>> Thank you
>> Greg B
>>
>>

 
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
NumberFormat not getting changing onFly changing the regional sett Dwipayan Das Microsoft Excel Programming 1 28th May 2010 07:55 PM
Changing row height in a data grid without changing font size =?Utf-8?B?S2FzZXk=?= Microsoft C# .NET 1 30th Jun 2006 12:20 AM
How to stop entire document style changing when changing 1 line? =?Utf-8?B?VHJveSBBLiBDb3VydG5leQ==?= Microsoft Word Document Management 4 1st May 2005 11:10 PM
Keeping Calendar times from changing when changing local time zone. George Lob Microsoft Outlook Discussion 1 22nd Nov 2004 05:14 PM
Difficulty in changing the Connection Server control path changing ... Samridhi Kumar Shukla Microsoft ASP .NET 1 30th Nov 2003 02:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:54 AM.