Select multiple adjacent cells of multiple cells without selecting

S

sjsjsjsjsjs

Select multiple adjacent cells of multiple cells without selecting adjacent
cells one by one. those cells looks like;
|Column A1 |Column A2|
|random characters | A |
|sjsjsjsjskkskskskk | B |
|wtwuwuwuuusisis | A |
|wuuuuusiwuwuwiu| A |
|euuuuuuuuuuuuuuu| B |
I am trying to select A1 cells that's adjacent of A2 cells without selecting
A1
cells one by one.

Thank you for your help.
 
S

sjsjsjsjsjs

I am trying to select A1 cells that's adjacent of "B" cells without selecting
A1 cells one by one
 
G

Gord Dibben

You need to do a little research into Excel cell referencing with regard to
rows and columns.

A1 and A2 are cells in Column A, not separate columns.


Gord Dibben MS Excel MVP
 
S

sjsjsjsjsjsjs

those cells looks like;
|Column A |Column B|
|random characters | Y |
|sjsjsjsjskkskskskk | Z |
|wtwuwuwuuusisis | Y |
|wuuuuusiwuwuwiu| Y |
|euuuuuuuuuuuuuuu| Z |
..
..
..
..
continue...
I am trying to select A cells that's adjacent of Y cells without selecting A
cells one by one, then
copy selected cells to Column C, and
keep rows of selected cells.
those cells will look like;
|Column C |
|random characters |
| |
|wtwuwuwuuusisis |
|wuuuuusiwuwuwiu|
| |
..
..
..
..
continue...

Thank you for your help.
 
R

Rick Rothstein

This macro should do what you want...

Sub MoveColAToColCFilterOnColB()
Dim X As Long, LastRow As Long, Answer As String
Answer = InputBox("What Column B character(s) do you want to filter on?")
If Len(Answer) > 0 Then
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For X = 1 To LastRow
If StrComp(Cells(X, "B").Value, Answer, vbTextCompare) = 0 Then
Cells(X, "B").Offset(, 1).Value = Cells(X, "B").Offset(, -1).Value
End If
Next
End If
End Sub

The code will ask you what text in Column B to search on and then perform
its copy operation.
 
R

Rick Rothstein

Another way you could approach this is to use formulas in your Column C
cells. Assuming you will want to "filter" on different text every now and
then, put the text string you want to look for in Column B in cell D1 (that
is, put the letter Y in D1) and put this formula in C1 and copy it down as
far as you like...

=IF(B1=$D$1,A1,"")
 
S

sjsjsjsjsjsjschanged

Thank you for your help.
Macro really worked.
re you working for Microsoft or have ou ever worked for Microsoft?
Did Microsoft ever publis A Super Input Routine?
my search in microsoft websites doesn't show any of information about book.

Thank you for your help.
 
R

Rick Rothstein

This is the problem with having your topic split... I just responded to this
message over in the other newsgroup.
 

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