Paste a single value into filtered Visible Cells - large file

dribj

New Member
Joined
Jul 1, 2013
Messages
1
Hi
I have a large excel file (2007) 135k+ rows. I would like to paste a single value (like "ok") into hundreds of blank cells in a filtered column. I've tried Go to Special / Visible Cells only - however I get an error that the area is too complex.

I assume I have to use VBA. I've read through a couple of posts but can't seem to get it quite right.

Can someone help?
thanks
jill
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi Jill, welcome to the MrExcel!

Provide autofiltering, select any cell in the filtered column and run this macro (via ALT-F8)
The visible cells of that column will be populated with default "ok" string.
Rich (BB code):
' Select any cell in filtered column to populate it by "ok"
Sub PopulateFilteredColumn()
 
  Dim ActCell As Range, Area As Range, Ok As String, Rng As Range
 
  ' Define the range
  Set ActCell = ActiveCell
  With ActiveSheet
    If .FilterMode Then
      Set Rng = Intersect(ActiveCell.EntireColumn, .AutoFilter.Range)
    End If
  End With
  If Rng Is Nothing Then
    MsgBox "Active cell is not in AutoFilter range", vbExclamation, "Try again"
    Exit Sub
  End If
  ' Exclude the title cell
  Set Rng = Rng.Resize(Rng.Rows.Count - 1).Offset(1)
 
  ' Ask for the filling string
  Rng.Select
  Ok = InputBox("Type the value for the selected visible cells", , "ok")
 
  ' Populate the visible cells of the range
  If Len(Ok) Then
    With Application
      .ScreenUpdating = False
      .EnableEvents = False
      For Each Area In Rng.Areas
        Area.SpecialCells(xlCellTypeVisible).Value = Ok
      Next
      .ScreenUpdating = True
      .EnableEvents = True
    End With
  End If
  ActCell.Select
 
End Sub
Regards
 
Last edited:
Upvote 0
Hi Jill, welcome to the MrExcel!

Provide autofiltering, select any cell in the filtered column and run this macro (via ALT-F8)
The visible cells of that column will be populated with default "ok" string.
Rich (BB code):
' Select any cell in filtered column to populate it by "ok"
Sub PopulateFilteredColumn()
 
  Dim ActCell As Range, Area As Range, Ok As String, Rng As Range
 
  ' Define the range
  Set ActCell = ActiveCell
  With ActiveSheet
    If .FilterMode Then
      Set Rng = Intersect(ActiveCell.EntireColumn, .AutoFilter.Range)
    End If
  End With
  If Rng Is Nothing Then
    MsgBox "Active cell is not in AutoFilter range", vbExclamation, "Try again"
    Exit Sub
  End If
  ' Exclude the title cell
  Set Rng = Rng.Resize(Rng.Rows.Count - 1).Offset(1)
 
  ' Ask for the filling string
  Rng.Select
  Ok = InputBox("Type the value for the selected visible cells", , "ok")
 
  ' Populate the visible cells of the range
  If Len(Ok) Then
    With Application
      .ScreenUpdating = False
      .EnableEvents = False
      For Each Area In Rng.Areas
        Area.SpecialCells(xlCellTypeVisible).Value = Ok
      Next
      .ScreenUpdating = True
      .EnableEvents = True
    End With
  End If
  ActCell.Select
 
End Sub
Regards

Wow - thanks so much. Nice touch with message box!! So - the error is the same (too complex)
"Microsoft Office Excel cannot create or use the data range reference because it is too complex. Try one or more of the following: 1. Use data that can be selected in one contiguous rectangle, 2. Use data from the same sheet.

So - maybe this file is so large, and the filtering is so disjointed - that I will not be able to place values in blank cells unless I manually paste them in (one by one)??
Again...thanks so much for replying!!!!
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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