Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing cell values between columns with macro

Hi I have a following problem

Let us assume what i have Excel sheet with two columns A and B

Current situation Wanted result
A B A B
Hs Hs Hs Hs
Kht Undef Kht Kht
HsMr Hs HsMr HsMr

I want to make a macro which copy/paste or replaces values in column B
based on cell location in column A, So if the cell value in column B
is Undef the value Undef in column B should be always replaced by
value of cell beside from column A. E.g If macro founds the value
"undef" or Value "*Mr" in column B it replaces these values in column
B on basis of values found in column A beside that particular cell.

Any ideas or related code to solve the problem?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing cell values between columns with macro

The description for Mr doesn't match the example. I worked according to the
description

Sub UpdateValues()
Dim i As Long

Application.ScreenUpdating = False
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If LCase(Cells(i, "B").Value) = "undef" Then
Cells(i, "B").Value = Cells(i, "A").Value
ElseIf LCase(Cells(i, "B").Value) Like "mr" Then
Cells(i, "B").Value = Cells(i, "A").Value
End If
Next i
Application.ScreenUpdating = True

End Sub

Save your data before running.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"spolk" wrote in message
om...
Hi I have a following problem

Let us assume what i have Excel sheet with two columns A and B

Current situation Wanted result
A B A B
Hs Hs Hs Hs
Kht Undef Kht Kht
HsMr Hs HsMr HsMr

I want to make a macro which copy/paste or replaces values in column B
based on cell location in column A, So if the cell value in column B
is Undef the value Undef in column B should be always replaced by
value of cell beside from column A. E.g If macro founds the value
"undef" or Value "*Mr" in column B it replaces these values in column
B on basis of values found in column A beside that particular cell.

Any ideas or related code to solve the problem?



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 lists of cells to absolute values using a macro Allerum30 Excel Discussion (Misc queries) 1 March 31st 09 07:30 PM
Cell for Changing Multiple Values in other columns Nadine Excel Worksheet Functions 3 December 13th 08 10:25 AM
Need to store changing values from one cell Emmie Excel Discussion (Misc queries) 5 September 17th 06 08:10 PM
Macro is changing values!!! aposatsk Excel Discussion (Misc queries) 0 August 15th 06 02:51 PM
changing cell values jamie&slings Excel Discussion (Misc queries) 1 May 3rd 06 01:29 AM


All times are GMT +1. The time now is 01:45 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"