Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Ldub
 
Posts: n/a
Default Replace variable row number in formulas

What I'm looking for is a macro that will replace the row number in a
formula with a new number that I designate through an input box.

Below is the code I have thus far. The problem lies in how I'm
defining the integer portion of the formula that I want to replace -
vbInteger (or vbLong) don't seem to work. Then finally I need to set
Section 2 in a loop through Column CN. Any advice would be greatly
appreciated!

---------------------------------------------------------------------------------------------------------------------------
Sub UpdateFormulas_2()

Dim LRowNumber As Long

LRowNumber = Application.InputBox _
(prompt:="Please enter the row number to update the formulas.",
_
Title:="Update Formulas", Type:=1)
If LRowNumber = False Then Exit Sub

Sheets("Review").Select


'Section 1 - Works just fine

ActiveCell.Select
If IsEmpty(Range("Input!A" & LRowNumber - 2).Value) Then
ActiveCell.Value = ""
Else
ActiveCell.Formula = "=CELL(""contents"",Input!A" & LRowNumber
- 2 & ")"
End If


'Section 2 - Needs help

ActiveCell.Offset(0, 1).Activate
ActiveCell.Select

ActiveCell.Formula = Replace(ActiveCell.Formula, vbInteger,
LRowNumber)

End If

Range("A1").Select

MsgBox ("The formulas were successfully updated to row " &
LRowNumber & ".")

End Sub
---------------------------------------------------------------------------------------------------------------------------

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
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
Formatting General to Number RJohnson701CTS Excel Discussion (Misc queries) 7 July 27th 05 04:16 PM
Need Formulas for counting multiple conditions OrdOff Excel Worksheet Functions 4 July 3rd 05 06:12 PM
Not plotting blank cells with formulas until number appears Excel Charts and Formulas Charts and Charting in Excel 1 April 1st 05 12:58 AM
How to Replace numbers and text with numbers only? Robert Judge Excel Worksheet Functions 3 November 5th 04 04:36 PM


All times are GMT +1. The time now is 02:27 PM.

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"