Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Macro to search range for a portion of a specific value and if findit - then paste formula in another cell.

The below formula works as written for a set value of "66-1007" in column B.. My problem is I need to search for a portion of that value as the 66-10 will remain constant, but the last 2 numbers might change (it is always a 7 character field). I have tried the * and # variables and have not had luck. Any help would be appreciated.

With Sheets("myworkshet")
Set rngToSearch = .Range(.Range("B2"), _
.Cells(Rows.Count, "B").End(xlUp))
End With

For Each rng In rngToSearch
With rng
If .Value = "66-1007" Then
Cells(.Row, "K").FormulaR1C1 = "=(RC[6]+RC[7])*0.08615"
End If
End With
Next rng
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default Macro to search range for a portion of a specific value and if find it - then paste formula in another cell.

On Tue, 5 Mar 2013 13:32:26 -0800 (PST), JenIT wrote:

The below formula works as written for a set value of "66-1007" in column B. My problem is I need to search for a portion of that value as the 66-10 will remain constant, but the last 2 numbers might change (it is always a 7 character field). I have tried the * and # variables and have not had luck. Any help would be appreciated.

With Sheets("myworkshet")
Set rngToSearch = .Range(.Range("B2"), _
.Cells(Rows.Count, "B").End(xlUp))
End With

For Each rng In rngToSearch
With rng
If .Value = "66-1007" Then
Cells(.Row, "K").FormulaR1C1 = "=(RC[6]+RC[7])*0.08615"
End If
End With
Next rng


Look at help for Like:

Try: if .value like "66-10##" then
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Macro to search range for a portion of a specific value and iffind it - then paste formula in another cell.

Perfect!!!! Thanks - amazing how one little word makes a world of difference. Your help is much appreciated.
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
Search for specific text within last non blank cell in a range Bevo Excel Worksheet Functions 2 September 5th 09 08:15 AM
Formula to Search one specific cell on another sheet. Dan C. Excel Discussion (Misc queries) 2 January 27th 09 06:49 AM
Extract a specific portion of text as new cell value Craig860 Excel Discussion (Misc queries) 6 March 20th 08 05:06 PM
I need to search for then extract a specific portion of cell data... Ken Excel Worksheet Functions 15 September 6th 06 11:53 AM
I need to search for then extract a specific portion of cell data... Ken Excel Programming 15 September 6th 06 11:53 AM


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