Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel VBA Special Cells by Column

Posted on 2013-02-06
2
Medium Priority
?
506 Views
Last Modified: 2013-02-06
I need to fill in blank spaces in column C in a spreadsheet.  The loop should start from the bottom of column C and step up. If the next cell up is blank, I need to copy and paste from the cell below.  The problem I'm having is my code selects all the blank cells and copies from the cell below. I just want this copying to happen in column C.
What am I missing?

Sub Macro2()

Dim LastRow As Long
Dim i As Long
 
 Application.ScreenUpdating = False
 
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    
     For i = LastRow To 1 Step -1
       Columns("C:C").Select
            Selection.SpecialCells(xlCellTypeBlanks).Select
            Selection.FormulaR1C1 = "=R[+1]C"    
        Next i
Application.ScreenUpdating = True

End Sub

Open in new window

0
Comment
Question by:minamina6
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 38859777
Without looping try

Range("C1:C" & lastrow).specialcells(xlcelltypeblanks).formular1c1= "=R[+1]C"
0
 

Author Closing Comment

by:minamina6
ID: 38859807
That worked. Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question