need code help or correction

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,232
Can any one pls help here..
Filter Col AB as a blank values. Select first row after header and give cell name as "False". Then copy this "False" value for rest of the filtered rows.

VBA Code:
LastRow = Range("A2", Range("A" & Rows.Count).End(xlUp)).Count

Range("AB1").Select
ActiveSheet.Range("$A$1:$AM$" & LastRow).AutoFilter Field:=28, Criteria1:="="

Dim r As Long
r = Range("A2:A" & Rows.Count).SpecialCells(xlVisible)(1).Row

Range("AB" & r).Select
ActiveCell.FormulaR1C1 = "FALSE"

'To get last row number after filter the COl AB
Dim FinalRowFiltered As Long, dataRange As Range
Set dataRange = Range("$AB$2:$AB$" & LastRow)
With dataRange.SpecialCells(xlCellTypeVisible)
    FinalRowFiltered = .Areas(.Areas.Count).Row + .Areas(.Areas.Count).Rows.Count
    'MsgBox FinalRowFiltered
End With

Range("AB" & r).Select
Selection.Copy
'instead of below line..
Range("AB3:AB" & FinalRowFiltered).Select
'I need in this way
Range("AB"&r+1 ":" "AB" & FinalRowFiltered).Select

Selection.SpecialCells(xlCellTypeVisible).Select
ActiveSheet.Paste
Application.CutCopyMode = False

Range("AB1").Select
ActiveSheet.Range("$A$1:$AM$" & LastRow).AutoFilter Field:=28, Criteria1:="False"
 
You have a couple of options.
Either format the whole of column AB as Text
OR
Use this:
(There is a single quote in front of the False.

Rich (BB code):
Range("AB1:AB" & Cells(Rows.Count, "A").End(xlUp).Row).SpecialCells(xlCellTypeBlanks) = "'False"
 
Last edited by a moderator:
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
You have a couple of options.
Either format the whole of column AB as Text
OR
Use this:
(There is a single quote in front of the False.

VBA Code:
Range("AB1:AB" & [B]Cells(Rows.Count, "A")[/B].End(xlUp).Row).SpecialCells(xlCellTypeBlanks) = [B]"'False"[/B]
Alex, what is the use of B .. I will reply you later once I do login to laptop.. I just msg you from mobile
 
Upvote 0
The [B][/B] is just because Alex accidently used VBA code tags rather than Rich code tags, you don't want them in your actual code line
I fixed that post.
Yes, formatting does not work well with VBA or Excel code tags (it translates to virtual XML code). It only works with Rich code tags.
 
Upvote 0
You have a couple of options.
Either format the whole of column AB as Text
OR
Use this:
(There is a single quote in front of the False.

Rich (BB code):
Range("AB1:AB" & Cells(Rows.Count, "A").End(xlUp).Row).SpecialCells(xlCellTypeBlanks) = "'False"
Alex.. It works perfect..!! Good.. Thank You for the kind understanding and help..

Dear Alex, Mark and Joe,
I need further help on my code on some next steps. Could you please allow me to post here only Or you need again new post..? This is some small help I needed.. kindly guide..
 
Upvote 0
I need further help on my code on some next steps. Could you please allow me to post here only Or you need again new post..? This is some small help I needed.. kindly guide..
The general rule of thumb is this:

1. If it is a follow-up question directly related to the previous question (meaning that the new question builds on the old one and really makes no sense without seeing the old one), then you can post it in the same thread.

2. If it is a new question where knowledge of the previous question is not needed (even if it is the same project), then post it to a new thread.

Note that the danger in posting unrelated questions to the same thread probably reduces the chances of a reply as less people will see it. Many people (including myself) use the "Unanswered threads" listing to look for new unanswered questions to help on. If you post a new question to an existing thread, most people will probably never see it (only those you have already replied on the thread will be notified of the new post). So that new question on the old thread will get a lot less people looking at it, reducing the chances of replies.
 
Upvote 0
The general rule of thumb is this:

1. If it is a follow-up question directly related to the previous question (meaning that the new question builds on the old one and really makes no sense without seeing the old one), then you can post it in the same thread.

2. If it is a new question where knowledge of the previous question is not needed (even if it is the same project), then post it to a new thread.

Note that the danger in posting unrelated questions to the same thread probably reduces the chances of a reply as less people will see it. Many people (including myself) use the "Unanswered threads" listing to look for new unanswered questions to help on. If you post a new question to an existing thread, most people will probably never see it (only those you have already replied on the thread will be notified of the new post). So that new question on the old thread will get a lot less people looking at it, reducing the chances of replies.
Hi Joe, Thank You for your reply. Yes, basically its depends on the same code and further.. Its basically one process which I'm trying to convert in macro..
This will not just help me but would be much easier to get from experts as they know what further I'm asking is..
 
Upvote 0
Hi Joe, Thank You for your reply. Yes, basically its depends on the same code and further.. Its basically one process which I'm trying to convert in macro..
This will not just help me but would be much easier to get from experts as they know what further I'm asking is..
Even if it is the same code, but a different question about it (i.e. not about filtering), it is typically best to post it in a new thread to get the most people looking at it.
Typically, you post back to the same question if you have a question on someone else's reply, or need a small tweak to the code they posted.

Remember that you can post your current code in new threads, and even include link back to other threads, if you think people may find that helpful.
 
Upvote 0

Forum statistics

Threads
1,215,172
Messages
6,123,438
Members
449,100
Latest member
sktz

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