Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Scanning cells to get their value

Hi all.

I'm just a beginner in VBA and Excel.

I must scan several contiguous cells, starting from left to right, checking
their value:
if the cell is empty, do nothing and move to check the next one at your
right

if the cell value is 0.25, get column ID (A, B, C...) and store, in another
cell, the value of the corresponding "ID"1 cell.
For example: if I check row 3 and I start checking from cell C3, if the 1st
cell = 0.25 is I3, I must store in my destination cell the value of I0.

Is anybody in there who can help me?

Thank you in advance.

--
Gnappo


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Scanning cells to get their value

Set DestRng = Range("M22")
for each cell in Selection
if abs(cell.value = .025) < .00001 then
DestRng = Cell.Address
end if
Next

Your description is not complete - but maybe the above will help.

--
Regards,
Tom Ogilvy


"Gnappo" wrote in message
...
Hi all.

I'm just a beginner in VBA and Excel.

I must scan several contiguous cells, starting from left to right,

checking
their value:
if the cell is empty, do nothing and move to check the next one at your
right

if the cell value is 0.25, get column ID (A, B, C...) and store, in

another
cell, the value of the corresponding "ID"1 cell.
For example: if I check row 3 and I start checking from cell C3, if the

1st
cell = 0.25 is I3, I must store in my destination cell the value of I0.

Is anybody in there who can help me?

Thank you in advance.

--
Gnappo




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Scanning cells to get their value

Thanks for your help but it does not seem to me to solve the problem but
maybe because I do know the Range object.
Honestly I do not see where you take the corresponding <same column but row
1 cell. It seems to me it gets any cell=0.25 within the range wheather I
must detect the 1st cell from the left.

I try to explain better:

I must scan cells from left to right and, as soon as I get the 1st = 0.25, I
must take the value of the <same column but row 1 cell and put it onto
another empty cell.

Then I must proceed to the (same Row, next+1 Column) next cell and check if
its value is still 0.25. If yes, I must move to the (same Row, next+1
Column) next cell and so on until I do not find the new 1st empty.

When I find the new 1st cell empty, I must take the value of the previous
<same column but row 1 cell and put it onto another empty cell.

By the way, thank you for your effort.

Gnappo


"Tom Ogilvy" wrote in message
...
Set DestRng = Range("M22")
for each cell in Selection
if abs(cell.value = .025) < .00001 then
DestRng = Cell.Address
end if
Next

Your description is not complete - but maybe the above will help.

--
Regards,
Tom Ogilvy


"Gnappo" wrote in message
...
Hi all.

I'm just a beginner in VBA and Excel.

I must scan several contiguous cells, starting from left to right,

checking
their value:
if the cell is empty, do nothing and move to check the next one at your
right

if the cell value is 0.25, get column ID (A, B, C...) and store, in

another
cell, the value of the corresponding "ID"1 cell.
For example: if I check row 3 and I start checking from cell C3, if the

1st
cell = 0.25 is I3, I must store in my destination cell the value of I0.

Is anybody in there who can help me?

Thank you in advance.

--
Gnappo






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Scanning cells to get their value

Sub FillCells()
Set rng = Selection
If rng.Rows.Count 1 Then
MsgBox "Select the cells in a single row to be searched"
Exit Sub
End If
If rng.Areas.Count 1 Then
MsgBox "Must be a contiguous set of cells in a single row"
Exit Sub
End If
For Each cell In Selection
Set rng1 = Range(cell.Offset(0, 1), rng(rng.Count))
If IsNumeric(cell.Value) And Not IsEmpty(cell.Value) Then
If Abs(cell.Value - 0.025) < 0.00001 Then
For Each cell2 In rng1
If IsEmpty(cell2) Then
cell2.Value = Cells(1, cell.Column).Value
Exit For
End If
Next
End If
End If
Next

End Sub

Might do what you want.

--
Regards,
Tom Ogilvy


"Gnappo" wrote in message
...
Thanks for your help but it does not seem to me to solve the problem but
maybe because I do know the Range object.
Honestly I do not see where you take the corresponding <same column but

row
1 cell. It seems to me it gets any cell=0.25 within the range wheather I
must detect the 1st cell from the left.

I try to explain better:

I must scan cells from left to right and, as soon as I get the 1st = 0.25,

I
must take the value of the <same column but row 1 cell and put it onto
another empty cell.

Then I must proceed to the (same Row, next+1 Column) next cell and check

if
its value is still 0.25. If yes, I must move to the (same Row, next+1
Column) next cell and so on until I do not find the new 1st empty.

When I find the new 1st cell empty, I must take the value of the previous
<same column but row 1 cell and put it onto another empty cell.

By the way, thank you for your effort.

Gnappo


"Tom Ogilvy" wrote in message
...
Set DestRng = Range("M22")
for each cell in Selection
if abs(cell.value = .025) < .00001 then
DestRng = Cell.Address
end if
Next

Your description is not complete - but maybe the above will help.

--
Regards,
Tom Ogilvy


"Gnappo" wrote in message
...
Hi all.

I'm just a beginner in VBA and Excel.

I must scan several contiguous cells, starting from left to right,

checking
their value:
if the cell is empty, do nothing and move to check the next one at

your
right

if the cell value is 0.25, get column ID (A, B, C...) and store, in

another
cell, the value of the corresponding "ID"1 cell.
For example: if I check row 3 and I start checking from cell C3, if

the
1st
cell = 0.25 is I3, I must store in my destination cell the value of

I0.

Is anybody in there who can help me?

Thank you in advance.

--
Gnappo








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
Scanning into Excel roryfan Excel Worksheet Functions 2 March 2nd 08 03:21 AM
Scanning Old Keith Excel Worksheet Functions 2 October 2nd 07 12:47 AM
virus scanning Duffy Setting up and Configuration of Excel 0 April 5th 07 01:18 AM
Bar Code Scanning Smileycam Excel Discussion (Misc queries) 1 July 5th 06 03:19 AM
Scanning down a column lashio Excel Discussion (Misc queries) 0 February 12th 06 07:22 PM


All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"