Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 02-08-2012, 02:42 PM
macropod's Avatar
macropod macropod is offline changing Windows 7 64bit changing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,527
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
With this code, simply select a cell and run the macro. It will ask whether you want to combine the cell's contents with those of the cell above, below, left or right.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing Changing accounts on same PC cjansley Outlook 1 07-27-2011 07:36 AM
changing 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft