select column c from cell c22 till the last empty row

BORUCH

Well-known Member
Joined
Mar 1, 2016
Messages
548
Office Version
  1. 365
Platform
  1. Windows
HI

i would like an excel VBA that does the following

i would like to select column c from cell C22 till the last empty cell in that column, then i also want to select the next column (column D from D22) whatever got selected in column c, (mirror image)

P.S My data set is filtered so i only want it to select on the filtered cells

THANKS
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try
Code:
Range("C22", Range("C" & Rows.Count).End(xlUp).Offset(, 1)).SpecialCells(xlVisible).Select
 
Upvote 0
Try
Code:
Range("C22", Range("C" & Rows.Count).End(xlUp).Offset(, 1)).SpecialCells(xlVisible).Select

thanks

i would like to add one more condition to this vba

the condition is that column C cell c22 it should say "ITEM #"

meaning to say that it only selects column c from cell C22 and the next column if in cell C22 it said the word "ITEM #"

so for ex. if the word "ITEM #" is displayed in cell B22 then it would select B22 till Last blank row and the next Column Column C


If THE WORD Item # doesn't exits at all in that row from A22 till.. it should display an error message that the word ITEM # is missing
 
Upvote 0
Try
Code:
Sub Chk1()
   Dim Fnd As Range
   Set Fnd = Rows(22).find("ITEM #", , , xlPart, , , False, , False)
   If Not Fnd Is Nothing Then
      Range(Fnd, Fnd.End(xlDown).Offset(, 1)).Select
   Else
      MsgBox "not found"
   End If

End Sub
 
Upvote 0
Try
Code:
Sub Chk1()
   Dim Fnd As Range
   Set Fnd = Rows(22).find("ITEM #", , , xlPart, , , False, , False)
   If Not Fnd Is Nothing Then
      Range(Fnd, Fnd.End(xlDown).Offset(, 1)).Select
   Else
      MsgBox "not found"
   End If

End Sub

Hi

two problems

#1 it the word item # is a formula its coming form a different sheet (=sheet23!B22) the code has to modified to look at values

#2 if the word ITEM # exits in column B22 then it doesn't select till the last empty cell only till the first empty cell

can that be fixed ?

thanks
 
Upvote 0
How about
Code:
Sub Chk1()
   Dim Fnd As Range
   Set Fnd = Range("22:22").find("ITEM #", , xlValues, xlPart, , , False, , False)
   If Not Fnd Is Nothing Then
      Range(Fnd, Cells(Rows.Count, Fnd.Column).End(xlUp).Offset(, 1)).Select
   Else
      MsgBox "not found"
   End If

End Sub
 
Upvote 0
actually i just realized that IN your last code it only selects till the first empty cell not till the last empty cell regardless of the word "ITEM #"
 
Upvote 0
How about
Code:
Sub Chk1()
   Dim Fnd As Range
   Set Fnd = Range("22:22").find("ITEM #", , xlValues, xlPart, , , False, , False)
   If Not Fnd Is Nothing Then
      Range(Fnd, Cells(Rows.Count, Fnd.Column).End(xlUp).Offset(, 1)).Select
   Else
      MsgBox "not found"
   End If

End Sub


Thanks a million that works perfectly
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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