Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Changing Value using vba

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Changing Value using vba


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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Changing Value using vba


This is how I would do it...

Sub IncrementYesses()
Dim C As Range
Dim FirstAddress As String
With Worksheets("STOCKLIST").Columns("F")
Set C = .Find("Yes", LookAt:=xlWhole, MatchCase:=False)
If Not C Is Nothing Then
FirstAddress = C.Address
Do
C.Offset(, -1).Value = C.Offset(, -1).Value + 1
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address < FirstAddress
End If
End With
End Sub

--
Rick (MVP - Excel)


"Greg B" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Changing Value using vba


Thank you Jacob it works perfectly
Greg B

"Jacob Skaria" wrote in message
...
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
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
Changing the range for averages with out changing the formula. JessLRC Excel Worksheet Functions 0 April 20th 10 03:10 PM
Changing case and also changing entered data hshayh0rn Excel Programming 1 May 15th 09 03:29 PM
Changing background colour when changing data in a cell Paoul Excel Discussion (Misc queries) 7 December 26th 08 07:25 AM
Autofill 1 column with changing data and changing range cdclayton Excel Programming 0 August 5th 08 04:37 PM
Changing footers on all worksheets without changing print set up KC Excel Discussion (Misc queries) 1 October 26th 07 03:31 PM


All times are GMT +1. The time now is 11:07 AM.

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"