5 6 7 8
25
36
49
64
Macro.png
5 6 7 8
25
36
49
64
Macro.png
Last edited by singh1982jeetuu; 06-26-2014 at 05:18 AM.
Hi,
It's not clear in which cells your values are. Can you please clarify?
Regards
Try this:
![]()
Sub LMP_Test() Dim lngCountValues As Long Dim rngRangeToApplyMultiply As Range Dim rngEachCell As Range Set rngRangeToApplyMultiply = Range("A1:M1") lngCountValues = 0 For Each rngEachCell In rngRangeToApplyMultiply lngCountValues = lngCountValues + 1 rngEachCell.Offset(lngCountValues).Value = rngEachCell ^ 2 Next rngEachCell End Sub
thanks.
but issue is if RANGE does not define.
If you will not define any range then how would programe know from which cell it has to start or which one is the last cell.
like 5,6,7,8 in columns
and we want the result on below
ag: A1=5
A2=5*5=25
B1=6
B3=6*6=36
C1=7
C4=7*7=47
that i understand by if I the range given (A1:Z1) and i have data on row only (A1:J1) so macro will give the result correctly on A1:J1 but for rest it will run useless.
If you have data in Range A1:J1 then why you are providing Range A1:Z1.![]()
its depend some time data in 5 line some data is 7 line.
or you can create a text box where I can enter the range.
Somthing like this:
![]()
Sub LMP_Test() Dim lngCountValues As Long Dim rngRangeToApplyMultiply As Range Dim rngEachCell As Range On Error Resume Next Set rngRangeToApplyMultiply = Application.InputBox("Select Range to apply data multiplication:-", "Data Range", , , , , , 8) On Error GoTo 0: Err.Clear If Not rngRangeToApplyMultiply Is Nothing Then lngCountValues = 0 For Each rngEachCell In rngRangeToApplyMultiply lngCountValues = lngCountValues + 1 rngEachCell.Offset(lngCountValues).Value = rngEachCell ^ 2 Next rngEachCell End If End Sub
Great Sir thanks a lot it is superb...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks