Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Editing a cell

Watch for linewrap.

I need to edit a cell with a number, add a = before it, a + after it
and then the number from the cell to the right of it.

There was a similar post about taking a cell content and adding a
number that was asked for:

Sub CreateFormula()
Dim dblNum As Double, dblAdd As Double


dblNum = ActiveCell.Value
dblAdd = Application.InputBox("Please enter the number to add.",
Type:=2)
ActiveCell.Formula = "= " & dblNum & "+" & dblAdd & ""


End Sub

How do I adjust it to put in another adjacent cell instead of the
requested number?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Editing a cell

Sub CreateFormula()
With ActiveCell
.Formula = "=" & .Value & "+" & .Offset(0,1).Value
End with
End Sub


--
Regards,
Tom Ogilvy



" wrote:

Watch for linewrap.

I need to edit a cell with a number, add a = before it, a + after it
and then the number from the cell to the right of it.

There was a similar post about taking a cell content and adding a
number that was asked for:

Sub CreateFormula()
Dim dblNum As Double, dblAdd As Double


dblNum = ActiveCell.Value
dblAdd = Application.InputBox("Please enter the number to add.",
Type:=2)
ActiveCell.Formula = "= " & dblNum & "+" & dblAdd & ""


End Sub

How do I adjust it to put in another adjacent cell instead of the
requested number?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Editing a cell

That worked. Now I need it to step through a range of rows, and if A 1
then perform the function until A is not populated


Tom Ogilvy wrote:
Sub CreateFormula()
With ActiveCell
.Formula = "=" & .Value & "+" & .Offset(0,1).Value
End with
End Sub


--
Regards,
Tom Ogilvy



" wrote:

Watch for linewrap.

I need to edit a cell with a number, add a = before it, a + after it
and then the number from the cell to the right of it.

There was a similar post about taking a cell content and adding a
number that was asked for:

Sub CreateFormula()
Dim dblNum As Double, dblAdd As Double


dblNum = ActiveCell.Value
dblAdd = Application.InputBox("Please enter the number to add.",
Type:=2)
ActiveCell.Formula = "= " & dblNum & "+" & dblAdd & ""


End Sub

How do I adjust it to put in another adjacent cell instead of the
requested number?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Editing a cell

For RowNdx = 50 To 1 Step -1
With Cells(RowNdx,"a")
If .Value 1 Then
.Formula = "=" & .Value & "+" & .Offset(0, 1).Value
End If
End with
Next
End Sub

If you are checking column A, but wish to put the formula in say column E

For RowNdx = 50 To 1 Step -1
With Cells(RowNdx,"a")
If .Value 1 Then
with .Offset(0,4)
.Formula = "=" & .Value & "+" & .Offset(0, 1).Value
end With
End If
End with
Next
End Sub

The reason your code doesn't work is you never change the activecell.

--
Regards,
Tom Ogilvy


" wrote:

I tried


For RowNdx = 50 To 1 Step -1
If Cells(RowNdx, "a").Value 1 Then
With ActiveCell
.Formula = "=" & .Value & "+" & .Offset(0, 1).Value
End With
End If
Next
End Sub

But for some reason it stays in the row it's in and performs the
operation 50 times. Why won't it go to another row?


wrote:
That worked. Now I need it to step through a range of rows, and if A 1
then perform the function until A is not populated


Tom Ogilvy wrote:
Sub CreateFormula()
With ActiveCell
.Formula = "=" & .Value & "+" & .Offset(0,1).Value
End with
End Sub


--
Regards,
Tom Ogilvy



" wrote:

Watch for linewrap.

I need to edit a cell with a number, add a = before it, a + after it
and then the number from the cell to the right of it.

There was a similar post about taking a cell content and adding a
number that was asked for:

Sub CreateFormula()
Dim dblNum As Double, dblAdd As Double


dblNum = ActiveCell.Value
dblAdd = Application.InputBox("Please enter the number to add.",
Type:=2)
ActiveCell.Formula = "= " & dblNum & "+" & dblAdd & ""


End Sub

How do I adjust it to put in another adjacent cell instead of the
requested number?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Editing a cell

Excellent!
You have saved the day.


Tom Ogilvy wrote:
For RowNdx = 50 To 1 Step -1
With Cells(RowNdx,"a")
If .Value 1 Then
.Formula = "=" & .Value & "+" & .Offset(0, 1).Value
End If
End with
Next
End Sub

If you are checking column A, but wish to put the formula in say column E

For RowNdx = 50 To 1 Step -1
With Cells(RowNdx,"a")
If .Value 1 Then
with .Offset(0,4)
.Formula = "=" & .Value & "+" & .Offset(0, 1).Value
end With
End If
End with
Next
End Sub

The reason your code doesn't work is you never change the activecell.

--
Regards,
Tom Ogilvy


" wrote:

I tried


For RowNdx = 50 To 1 Step -1
If Cells(RowNdx, "a").Value 1 Then
With ActiveCell
.Formula = "=" & .Value & "+" & .Offset(0, 1).Value
End With
End If
Next
End Sub

But for some reason it stays in the row it's in and performs the
operation 50 times. Why won't it go to another row?


wrote:
That worked. Now I need it to step through a range of rows, and if A 1
then perform the function until A is not populated


Tom Ogilvy wrote:
Sub CreateFormula()
With ActiveCell
.Formula = "=" & .Value & "+" & .Offset(0,1).Value
End with
End Sub


--
Regards,
Tom Ogilvy



" wrote:

Watch for linewrap.

I need to edit a cell with a number, add a = before it, a + after it
and then the number from the cell to the right of it.

There was a similar post about taking a cell content and adding a
number that was asked for:

Sub CreateFormula()
Dim dblNum As Double, dblAdd As Double


dblNum = ActiveCell.Value
dblAdd = Application.InputBox("Please enter the number to add.",
Type:=2)
ActiveCell.Formula = "= " & dblNum & "+" & dblAdd & ""


End Sub

How do I adjust it to put in another adjacent cell instead of the
requested number?





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
In cell editing Dewayne Excel Discussion (Misc queries) 2 January 31st 09 05:23 AM
Editing in Cell Dale Fye Excel Discussion (Misc queries) 5 October 17th 07 06:06 PM
Editing in a cell John English New Users to Excel 2 February 4th 07 06:03 AM
Disabling Cell Editing programmingrookie Excel Programming 4 July 26th 05 05:07 PM
Cell Editing remco2mill New Users to Excel 2 February 11th 05 06:17 PM


All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"