#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Hardcode

Hello. Is there a way to have vba scan an entire sheet (activesheet) and
hardcode any cells that have a VLookup formula in the cell? I was going to
just hardcode the entire sheet, but i also have a lot of sum formulas that I
can't have hardcoded. Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Hardcode

One way:

Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Cells
If UCase(Left(rCell.FormulaR1C1, 8)) = "=VLOOKUP" Then rCell.Value =
rCell.Value
Next rCell

HTH

"Steph" wrote:

Hello. Is there a way to have vba scan an entire sheet (activesheet) and
hardcode any cells that have a VLookup formula in the cell? I was going to
just hardcode the entire sheet, but i also have a lot of sum formulas that I
can't have hardcoded. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hardcode

Maybe...

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range

With ActiveSheet
Set myRng = Nothing
On Error Resume Next
Set myRng = .Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No Formulas!"
Exit Sub
End If

For Each myCell In myRng.Cells
If myCell.Formula Like "*VLOOKUP(*" Then
myCell.Value = myCell.Value
End If
Next myCell
End With
End Sub

But it will get fooled with formulas like:
=a1&"Steph, don't forget to include your =VLOOKUP() formula here"

But that's probably not too likely?????



Steph wrote:

Hello. Is there a way to have vba scan an entire sheet (activesheet) and
hardcode any cells that have a VLookup formula in the cell? I was going to
just hardcode the entire sheet, but i also have a lot of sum formulas that I
can't have hardcoded. Thanks.


--

Dave Peterson
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
Y Axis : Dynamically Hardcode Min/Max Values? RayportingMonkey Charts and Charting in Excel 1 February 21st 08 06:06 PM
hardcode a column in a formula AHizon via OfficeKB.com Excel Worksheet Functions 2 October 16th 07 01:33 AM
Hardcode links - loop through sheets Steph[_3_] Excel Programming 2 March 2nd 06 03:26 AM
Hardcode Links - edit my code please? Steph[_6_] Excel Programming 1 October 26th 05 04:14 PM
Change hardcode to ....? Stuart[_21_] Excel Programming 3 April 30th 05 05:53 PM


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