![]() |
|
#8
|
||||
|
||||
|
Hi gsrikanth,
It is difficult to know what you want, because you don't explain it very well and I have to guess what you mean. Try the following but, if it's not what you want, I'm not going to spend any more time on it unless you give a clear explanation. Code:
Sub CombineValues()
Dim StrTgt As String, i As Long, j As Long
With ActiveCell
StrTgt = UCase(Left(Trim(InputBox("Combine with cell:" & vbCr & _
"(A)bove" & vbCr & "(B)elow" & vbCr & _
"(L)eft" & vbCr & "(R)ight", "Get Source Direction")), 1))
If StrTgt = "" Then Exit Sub
Select Case StrTgt
Case "A": i = -1: j = 0
Case "B": i = 1: j = 0
Case "L": i = 0: j = -1
Case "R": i = 0: j = 1
Case Else: Exit Sub
End Select
If .Column + i >= 0 And .Row + j >= 0 Then
If IsNumeric(Evaluate(.Offset(i, j).Value)) And IsNumeric(Evaluate(.Value)) Then
.Value = Evaluate(.Offset(i, j).Value) + Evaluate(.Value)
Else
.Value = .Offset(i, j).Value & " " & .Value
End If
.NumberFormat = "General"
End If
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Changing accounts on same PC
|
cjansley | Outlook | 1 | 07-27-2011 07:36 AM |
Changing the From field
|
jerem | Outlook | 2 | 10-29-2010 03:04 PM |
| Changing list of Value | xmadnet | Word | 0 | 09-07-2010 01:48 PM |
| Changing Word doc to .txt | cialili | Word | 1 | 08-02-2010 12:38 PM |
| changing font size without changing leading | carolns | Word | 1 | 09-14-2009 12:30 PM |