move to the cell on the right, my code not working pls help

K

kiwiiii09

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top