Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default move to the cell on the right, my code not working pls help

Hi

Pls assist me. Thank you.
My macro will move to the cell on the right when the current cell is
occupied & stop once it has been set to the new empty cell.

Sample of my data
A1 A2
C1 123

burner_cell is the cell containing 123

i have written some code to do this but i can't seems to get it to
work

my code =

Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = Range("B8")


While counter < 13
If Not (IsEmpty(burner_cell)) Then
burner_cell = burner_cell.Offset(0, 1)
counter = counter + 1
End If
Wend

then i use burner_cell(new empty cell) to save the result of some
calculation

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default move to the cell on the right, my code not working pls help

I'll put some questions in the code

" wrote:

Hi

Pls assist me. Thank you.
My macro will move to the cell on the right when the current cell is
occupied & stop once it has been set to the new empty cell.

Sample of my data
A1 A2
C1 123

burner_cell is the cell containing 123

i have written some code to do this but i can't seems to get it to
work

my code =

Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = Range("B8")


While counter < 13
If Not (IsEmpty(burner_cell)) Then
burner_cell = burner_cell.Offset(0, 1) '<~~~do you want to reset the range name or reset the value in the range? THis resets the value in the range. If you want to reset the range name, you'll need to include SET before your statement
counter = counter + 1
End If
Wend

then i use burner_cell(new empty cell) to save the result of some
calculation


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default move to the cell on the right, my code not working pls help

You never increment burner_cell, you are looking at Range("B8") for a value
forever, because if it is blank you need to increment to search another cell
--
-John Northwest11
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

Hi

Pls assist me. Thank you.
My macro will move to the cell on the right when the current cell is
occupied & stop once it has been set to the new empty cell.

Sample of my data
A1 A2
C1 123

burner_cell is the cell containing 123

i have written some code to do this but i can't seems to get it to
work

my code =

Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = Range("B8")


While counter < 13
If Not (IsEmpty(burner_cell)) Then
burner_cell = burner_cell.Offset(0, 1)
counter = counter + 1
End If
Wend

then i use burner_cell(new empty cell) to save the result of some
calculation


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default move to the cell on the right, my code not working pls help

You are right your code did nothing. Try this. counter never got
incremented and the code was always looking at the same cell.

Sub xyz()
Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = Range("B8")


While counter < 13
If Not (IsEmpty(burner_cell.Offset(0, counter))) Then
burner_cell = burner_cell.Offset(0, counter)
End If
counter = counter + 1
Wend

End Sub


" wrote:

Hi

Pls assist me. Thank you.
My macro will move to the cell on the right when the current cell is
occupied & stop once it has been set to the new empty cell.

Sample of my data
A1 A2
C1 123

burner_cell is the cell containing 123

i have written some code to do this but i can't seems to get it to
work

my code =

Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = Range("B8")


While counter < 13
If Not (IsEmpty(burner_cell)) Then
burner_cell = burner_cell.Offset(0, 1)
counter = counter + 1
End If
Wend

then i use burner_cell(new empty cell) to save the result of some
calculation


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default move to the cell on the right, my code not working pls help

Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = ws.Range("B8") '<== qualify the location


While counter < 13
If Not (IsEmpty(burner_cell)) Then
set burner_cell = burner_cell.Offset(0, 1) '<== use SET
counter = counter + 1
End If
Wend

Another approach

set Burner_Cell = ws.Cells(8,256).End(xltoLeft)(1,2)
if Burner_Cell.Column 22 then exit sub
if Burner_Cell.Column < 8 then _
set Burner_Cell = ws.Range("B8")

--
Regards,
Tom Ogilvy


" wrote:

Hi

Pls assist me. Thank you.
My macro will move to the cell on the right when the current cell is
occupied & stop once it has been set to the new empty cell.

Sample of my data
A1 A2
C1 123

burner_cell is the cell containing 123

i have written some code to do this but i can't seems to get it to
work

my code =

Dim burner_cell As Range

Dim WS As Worksheet, WS2 As Worksheet
Dim counter As Integer

counter = 1
Set WS = Worksheets("Summary")
Set burner_cell = Range("B8")


While counter < 13
If Not (IsEmpty(burner_cell)) Then
burner_cell = burner_cell.Offset(0, 1)
counter = counter + 1
End If
Wend

then i use burner_cell(new empty cell) to save the result of some
calculation




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default move to the cell on the right, my code not working pls help

Thanks for the tips everyone, i got my code to work as i would like it
to do.

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
VBA Code - Find & Move Youlan Excel Discussion (Misc queries) 4 October 28th 08 07:26 PM
VBA code to move contents from one cell to another Trina Excel Programming 3 August 22nd 06 09:02 PM
Edit / Move or copy sheet stopped working in Excel 2003 kris2u Excel Worksheet Functions 0 October 4th 05 08:20 PM
VB code to move cursor 'one cell down? StargateFan[_3_] Excel Programming 6 May 21st 04 02:42 AM
How to move files from the code Ana Excel Programming 3 May 17th 04 03:03 PM


All times are GMT +1. The time now is 08:23 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"