#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro

Hello
i have an Excel spreadsheet that contains 6 columns.
column1 is always populated. columns 2-6 contain other
information. the entries for columns 2-6 for any row
depend on the value on column1 for that row.
now there are several instances where there are blank
values in columns 2-6 for some rows, even though column1
for that row has an entry.
i need to write a macro that will for each of columns 2-6
find a blank cell, then perform a vlookup based on the
value in column1 for that row, then go to the next blank
and do the same thing, then repeat for each of columns 2-6.
the vlookup will find the missing data in another Excel
spreadsheet.
as this changes each month i want to use a macro to
automate this as opposed to manually doing vlookup each
month
i have no idea how to write such a macro. can anyone give
me some ideas,
thanks a lot
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro

One way:

Public Sub FillInData()
Dim rSource As Range
Dim rCell As Range
Dim rFound As Range

Set rSource = _
Workbooks("Workbook2.xls").Sheets("Sheet1").Range( "A:A")
For Each rCell In Columns("B:F").SpecialCells( _
xlCellTypeBlanks)
Set rFound = rSource.Find( _
What:=Cells(rCell.Row, 1).Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not rFound Is Nothing Then _
rCell.Value = rFound(1, rCell.Column)
Next rCell
End Sub

I assumed that your source workbook would also have 6 columns. If it has
only two, change

rCell.Value = rFound(1, rCell.Column)

to

rCell.Value = rFound(1, 2)


Note that Workbook2 must be open before starting this macro.

In article ,
"MikeM" wrote:

Hello
i have an Excel spreadsheet that contains 6 columns.
column1 is always populated. columns 2-6 contain other
information. the entries for columns 2-6 for any row
depend on the value on column1 for that row.
now there are several instances where there are blank
values in columns 2-6 for some rows, even though column1
for that row has an entry.
i need to write a macro that will for each of columns 2-6
find a blank cell, then perform a vlookup based on the
value in column1 for that row, then go to the next blank
and do the same thing, then repeat for each of columns 2-6.
the vlookup will find the missing data in another Excel
spreadsheet.
as this changes each month i want to use a macro to
automate this as opposed to manually doing vlookup each
month
i have no idea how to write such a macro. can anyone give
me some ideas,
thanks a lot
Mike

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"