Excel/Excel Macro

Advertisement


Question
My excel worksheet has A and B Columns with numbers.  Column-A shows figures which are repeated in two or three cells.  Column-B has corresponding numbers against value in Column-A and sometimes the columns are blank. I need a macro to fill blank cells in Column-B with the same numbers corresponding to Column-A value. Eg:

A1 - 1500   B1 -7000
A2 - 1500   B2 -7000
A3 - 1500   B3 -    (Blank)

A4 - 2500   B4 -4000
A5 - 2500   B5 -    (Blank)

A6 - 5000   B1 -    (Blank)
A7 - 5000   B2 -8000
A8 - 5000   B3 -    (Blank)

A9 - 7000   B4 -3000
A10- 7000   B5 -    (Blank)

Result in Column-B should be as follows:

B1 - 7000
B2 - 7000
B3 - 7000
B4 - 4000
B5 - 4000
B6 - 8000
B7 - 8000
B8 - 8000
B9 - 3000
B10- 3000

regards

Varghese

Answer
Hi use this code to fill empty cells



Sub rellenacel()
Dim fila, uf As Integer
fila = 2
b = ActiveSheet.Name
uf = Sheets(b).Range("A" & Rows.Count).End(xlUp).Row
While Sheets(b).Cells(fila, 1) <> Empty
d = Sheets(b).Cells(fila, 1)
If Sheets(b).Cells(fila, 2) = Empty Then
Sheets(b).Cells(fila, 2) = d
End If
fila = fila + 1
Wend
End Sub



Visit http://programarexcel.com find examples of macros that can be of use
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


marcrodos

Expertise

Expert programming macros or visual basic VBA that can help automate your Excel spreadsheets using VBA programming or macros to excel, forms and other procedures related to Macros. I also have an excellent command of Excel in almost its entirety, formulas, graphs, dynamic tables. In http://programarexcel.blogspot.com o www.programarexcel.com examples can download free excel macros programmed in VBA, macros can be downloaded and adapted to the project that you're doing to automate excel www.programarexcel.com

Experience

For several years, use Microsoft Excel on a daily basis, more specifically in my work, which is why over several years I have compiled a wealth of knowledge about their operation, adding to the basic operation of coding excel VBA macros to automate repetitive tasks . I serve as an expert in excel also in www.todoexpertos.com site, which I enjoy a great reputation. In http://programarexcel.blogspot.com o www.programarexcel.com examples can download free excel macros programmed in VBA, macros can be downloaded and adapted to the project that you're doing to automate excel www.programarexcel.com

Organizations
http://www.programarexcel.blogspot.com http://www.programarexcel.com

Publications
In public http://www.programarexcel.com o www.programarexcel.com continuously macro examples that readers can download for free and adapt to the needs of each project in excel that has the web page visitor

Education/Credentials
My profession's is a Chartered Accountant with experience in Excel, especially in VBA or macro programming, but also in the formulas and everything related to excel, I graduated several years ago at the National University of Cordoba, now I practice my profession in which a basic tool is excel. www.programarexcel.com

Awards and Honors
http://www.programarexcel.blogspot.com http://www.programarexcel.com

Past/Present Clients
http://www.programarexcel.blogspot.com http://www.programarexcel.com

©2016 About.com. All rights reserved.