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

the entries A1 to A5 are
55 44 32
market value
11 22 33
33 44 55
r venkat


I created a sub like this


Public Sub TEST()
Dim i, j As Long
Dim v
Dim cell, myrange As Range
Set myrange = Range(Range("a1"), Range("a1").End(xlDown))
For Each cell In myrange
If IsNumeric(Left(cell, 1)) Then
i = WorksheetFunction.Search(" ", cell, 1)
j = WorksheetFunction.Search(" ", cell, i + 1)
v = Mid(cell, 1, i - 1) & Mid(cell, i + 1, j - i - 1) & Mid(cell, j + 1,
Len(cell) - j)
msgbox v
cell = v 'the cell value does not change
End If
Next cell
End Sub

but the cell value in A1, A3,A4 do not change why?
msgbox v gives correct value viz 554432
even ?cell in the immediate window gives 554432 but in A1 (and in A3 and
A4) the value does not change

what is the mistake I am doing?

excel 2002 (XP)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default cell not changing

when you separate dims with a comma they do not all get dim as whatever
you specify. they each need to be set separatly like this:
Dim cell as Range, myrange as Range

HTH

Die_Another_Day

R..VENKATARAMAN wrote:
the entries A1 to A5 are
55 44 32
market value
11 22 33
33 44 55
r venkat


I created a sub like this


Public Sub TEST()
Dim i, j As Long
Dim v
Dim cell, myrange As Range
Set myrange = Range(Range("a1"), Range("a1").End(xlDown))
For Each cell In myrange
If IsNumeric(Left(cell, 1)) Then
i = WorksheetFunction.Search(" ", cell, 1)
j = WorksheetFunction.Search(" ", cell, i + 1)
v = Mid(cell, 1, i - 1) & Mid(cell, i + 1, j - i - 1) & Mid(cell, j + 1,
Len(cell) - j)
msgbox v
cell = v 'the cell value does not change
End If
Next cell
End Sub

but the cell value in A1, A3,A4 do not change why?
msgbox v gives correct value viz 554432
even ?cell in the immediate window gives 554432 but in A1 (and in A3 and
A4) the value does not change

what is the mistake I am doing?

excel 2002 (XP)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default cell not changing

i think my mistak is c=v
it should be
c.value=v


"Die_Another_Day" wrote in message
oups.com...
when you separate dims with a comma they do not all get dim as whatever
you specify. they each need to be set separatly like this:
Dim cell as Range, myrange as Range

HTH

Die_Another_Day

R..VENKATARAMAN wrote:
the entries A1 to A5 are
55 44 32
market value
11 22 33
33 44 55
r venkat


I created a sub like this


Public Sub TEST()
Dim i, j As Long
Dim v
Dim cell, myrange As Range
Set myrange = Range(Range("a1"), Range("a1").End(xlDown))
For Each cell In myrange
If IsNumeric(Left(cell, 1)) Then
i = WorksheetFunction.Search(" ", cell, 1)
j = WorksheetFunction.Search(" ", cell, i + 1)
v = Mid(cell, 1, i - 1) & Mid(cell, i + 1, j - i - 1) & Mid(cell, j + 1,
Len(cell) - j)
msgbox v
cell = v 'the cell value does not change
End If
Next cell
End Sub

but the cell value in A1, A3,A4 do not change why?
msgbox v gives correct value viz 554432
even ?cell in the immediate window gives 554432 but in A1 (and in A3 and
A4) the value does not change

what is the mistake I am doing?

excel 2002 (XP)




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
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
Changing background colour when changing data in a cell Paoul Excel Discussion (Misc queries) 7 December 26th 08 07:25 AM
Cell colors or text color changing when date in cell gets closer. Chase Excel Worksheet Functions 5 October 19th 06 08:57 AM
changing a cell to changing the link Jared Excel Worksheet Functions 7 May 8th 06 08:41 AM


All times are GMT +1. The time now is 08:13 PM.

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"