Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Take active cell value in for loop and offset based on another cellvalue for columns to offset

I have the following incomplete macro, where a user selects a range.
We then loop through the range going thru each column in first row of
range then down to next row and across each column etc. etc.

When I hit a cell who's value is 0, it want to take that value and
place it in a cell offset from the active cell inside for loop. The
column offset will come from current row (in for loop) and column b.
The row offset i would envision as being some constant value let say
10 for arguments sake.

For example, let say my selected range is C2:M10
My first cell within range 0 is H2
In cell B2 lets say it's 4
Now we want to take the value from H2 and place it in D12 (the 4 in B2
will offset the active cell by 4 columns to the left and the constant
10 offset the rows from active cell by 10. The for loop will then
continue until we hit the next cell 0. Assuming we are still on row 2
the offset value for columns remains B2, but once we loop to next row
the offset for column would be B3 etc etc.

In the code below i'm having difficulty putting into code what i
describe above, hopefully someone can help.


Sub Test()

Dim row As Range
Dim cell As Range

Dim UserRange1 As Range
On Error GoTo Canceled
Set UserRange1 = Application.InputBox(Prompt:="Please Select Range",
Title:="Range Select", Type:=8)

For Each row In UserRange1.Rows
For Each cell In row.Cells
If cell 0 Then

this is where i came unstuck...........

End If
Next cell
Next row
Canceled:

End Sub
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
Copy (A2:A26) paste, offset one cell, do it again. Loop 256 tim RyGuy Excel Programming 4 October 22nd 09 08:25 PM
move from active cell offset in macro april Excel Discussion (Misc queries) 5 October 18th 09 05:02 PM
Offset of active cell RichardGarfield Excel Programming 5 January 12th 09 12:56 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Programming 4 September 28th 07 09:59 PM


All times are GMT +1. The time now is 11:15 AM.

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"