cell movement

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
hi everyone, i need the command to move / highlight cells in a macro i.e. how to make it highlight the cell to the left, right, top and bottom.

and if you know how to loop the comand in the macro untill it does find any more data in the list pleaselet me know

thanks in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
left by one cell , right by one, up by one and down by one please.

what it needs to do at the end is read a cell run a nested if statement if true copy the required 5 cells from that row into another sheet and drop down a row and move across to the next reference cell directly below the first (same event if the if statement was false) and run the nested if again on that row untill it drops a row and finds no data!

thank you!
 
Upvote 0
Sorry don't have a clue what you are wanting!
Not enough information.
What do you have now, what data, what cells?
What do you want to end up with, and where?
Do you want VBA code or Sheet Formulas?
 
Upvote 0
no probs what i have i'll show you!

ok what i need to do is this

two sheets 1st (shift left data) is for data and calculations, 2nd (shift left abuse) is for results.

on sheet 1 - (stating from row 9) cols m & n have ref data in them, i need to run an if statement asking if the val in n is larger than in m. if yes copy cells o9,p9,q9,r9,s9 and paste them into sheet 2 from col a row 2.

Once done OR if false ignore that row, go to the next row and run again untill all rows which return TRUE from the if statement have been copied across to sheet 2.

Untill the macro loop finds empty data in col n and stops


HOPE I MADE A LITTLE MORE SENSE THAT TIME and thanks any help you can give me.
 
Upvote 0
Try this:


Sub myTestThenMove()
'Standard module code, like: Module1.
Dim r As Object
Dim n&

Application.ScreenUpdating = False
Worksheets("Sheet1").Select

For Each r In Worksheets("Sheet1").UsedRange.Rows
n = r.Row

If Worksheets("Sheet1").Cells(n, 14) > Worksheets("Sheet1").Cells(n, 13) Then
Worksheets("Sheet1").Range(Cells(n, 15), Cells(n, 19)).Copy _
Destination:=Worksheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
Else
End If
Next r

Application.CutCopyMode = True
Application.ScreenUpdating = True
End Sub
 
Upvote 0
ive put it in and its sort of working, its begining at row 8 not nine but is only bringing out one row onto the other sheet not repeating the process for the other rows on sheet 1

it must continue extracting the data untill it sees nothing in sheet 1 col n
 
Upvote 0
I used:

Each r In Worksheets("Sheet1").UsedRange.Rows

"UsedRange" which works for full worksheet ranges, if you have blank rows and columns between some data then this does not work. It needs to be converted to a defined working range

Like:

myBotR = Sheets("Sheet1").Range("N65536").End(xlUp).Row

myRng = Sheets("Sheet1").Range(Cells(1, 1), Cells(myBotR, 19)
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,741
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top