![]() |
|
|
|
#1
|
|||
|
|||
|
change to macro
Code:
Sub Test()
Dim rngToChange As Range
Dim iMultiplier As String
Dim iDivisor As String
With Sheets("Sheet1")
iMultiplier = .Range("A1").Value
iDivisor = .Range("A2").Value
.Range("A3").Value = iMultiplier & iDivisor
Set rngToChange = .Range("B1:B" & .Cells(Rows.Count, "B").End(xlUp).Row)
.Range("A3").Copy
rngToChange.PasteSpecial _
Paste:=xlAll, Operation:=xlMultiply, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End With
End Sub
![]() convert to application.inputbox Last edited by macropod; 02-06-2012 at 07:36 PM. Reason: Added code tags |
|
#2
|
||||
|
||||
|
Hi gsrikanth,
Other than apparently wanting to concatenate the data from two ranges, it's not at all clear what you want the input boxes for. Also, when posting code, please use code tags.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Quote:
in sheet to i calculate second columns data by keeping forumula =1/2 that value should add to first column any alternative data is adjucent only it should add like add comment i need add cell by crtl+j macro |
|
#4
|
||||
|
||||
|
I've look at your workbook. It's nothing like the image attached in your first post and there is still nothing to indicate what any input boxes might be used for.
Perhaps you want code like the following: Code:
Sub CombineValues()
Dim i As Long
With ActiveSheet
For i = 1 To .Range("B" & .Cells.SpecialCells(xlCellTypeLastCell).Row).End(xlUp).Row
.Range("B" & i).Value = .Range("A" & i).Value + Evaluate(.Range("B" & i).Value)
.Range("B" & i).NumberFormat = "General"
Next
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
Quote:
change this Evaluate(.Range("B" & i).Value) |
|
#6
|
||||
|
||||
|
Hi gsrikanth,
Try: Code:
Sub CombineValues()
Dim i As Long
With ActiveSheet
For i = 1 To .Cells.SpecialCells(xlCellTypeLastCell).Row
If IsNumeric(Evaluate(.Range("A" & i).Value)) And IsNumeric(Evaluate(.Range("B" & i).Value)) Then
.Range("B" & i).Value = Evaluate(.Range("A" & i).Value) + Evaluate(.Range("B" & i).Value)
Else
.Range("B" & i).Value = .Range("A" & i).Value & " " & .Range("B" & i).Value
End If
.Range("B" & i).NumberFormat = "General"
Next
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
i have to convert in different cells like a3,b23,c1,d50.
i need is, if i click in a3 adjecent of a3, i.e.,a2 come in a3 click or macro |
|
#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] |
|
#9
|
|||
|
|||
|
Great! Goal.......! thanks for patients you look on me, solved
|
|
|
|
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 |