Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jac Jac is offline
external usenet poster
 
Posts: 58
Default Using Macro to fill up data in coulmn

hi,

I have a macro coded as below:-

Sub LookupValues()

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Documents and Settings\Jac\Desktop\Book2.xls'
_myRange,2,0)"
Selection.AutoFill Destination:=Range("B1:B3")

End Sub

But this macro can only fill up the specific range with values which is
Range("B1:B3") but I wish that I could have the way that the macro can help
to fill up values for range with unknown length, which mean sometimes the
range could be longer or sometimes the length could be shorter.

I have tried out some methods but they seem like not working out as
expected. So someone please help to advise....

Thanking in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Macro to fill up data in coulmn

Can you pick out a column that would tell you how far to fill?

Dim LastRow as long
'I'm using column C
lastrow = cells(rows.count,"C").end(xlup).row

.....

selection.autofill destination:=range("B1:B" & lastrow)



Jac wrote:

hi,

I have a macro coded as below:-

Sub LookupValues()

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Documents and Settings\Jac\Desktop\Book2.xls'
_myRange,2,0)"
Selection.AutoFill Destination:=Range("B1:B3")

End Sub

But this macro can only fill up the specific range with values which is
Range("B1:B3") but I wish that I could have the way that the macro can help
to fill up values for range with unknown length, which mean sometimes the
range could be longer or sometimes the length could be shorter.

I have tried out some methods but they seem like not working out as
expected. So someone please help to advise....

Thanking in advance.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jac Jac is offline
external usenet poster
 
Posts: 58
Default Using Macro to fill up data in coulmn

hi,

first of all thanks for the help!

something to clarify is that the statement below:-
selection.autofill destination:=range("B1:B" & lastrow)
Is it mean that values will be filled up in range B1:B3 & in range of column
C?



"Dave Peterson" wrote:

Can you pick out a column that would tell you how far to fill?

Dim LastRow as long
'I'm using column C
lastrow = cells(rows.count,"C").end(xlup).row

.....

selection.autofill destination:=range("B1:B" & lastrow)



Jac wrote:

hi,

I have a macro coded as below:-

Sub LookupValues()

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Documents and Settings\Jac\Desktop\Book2.xls'
_myRange,2,0)"
Selection.AutoFill Destination:=Range("B1:B3")

End Sub

But this macro can only fill up the specific range with values which is
Range("B1:B3") but I wish that I could have the way that the macro can help
to fill up values for range with unknown length, which mean sometimes the
range could be longer or sometimes the length could be shorter.

I have tried out some methods but they seem like not working out as
expected. So someone please help to advise....

Thanking in advance.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
Jac Jac is offline
external usenet poster
 
Posts: 58
Default Using Macro to fill up data in coulmn

hi, Dave

I think I get what the code means!
Thanks :)


"Jac" wrote:

hi,

I have a macro coded as below:-

Sub LookupValues()

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Documents and Settings\Jac\Desktop\Book2.xls'
_myRange,2,0)"
Selection.AutoFill Destination:=Range("B1:B3")

End Sub

But this macro can only fill up the specific range with values which is
Range("B1:B3") but I wish that I could have the way that the macro can help
to fill up values for range with unknown length, which mean sometimes the
range could be longer or sometimes the length could be shorter.

I have tried out some methods but they seem like not working out as
expected. So someone please help to advise....

Thanking in advance.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Macro to fill up data in coulmn

Just in case...

It uses column C to determine the last row to fill. But it actually fills the
cells in column B.


Jac wrote:

hi,

first of all thanks for the help!

something to clarify is that the statement below:-
selection.autofill destination:=range("B1:B" & lastrow)
Is it mean that values will be filled up in range B1:B3 & in range of column
C?

"Dave Peterson" wrote:

Can you pick out a column that would tell you how far to fill?

Dim LastRow as long
'I'm using column C
lastrow = cells(rows.count,"C").end(xlup).row

.....

selection.autofill destination:=range("B1:B" & lastrow)



Jac wrote:

hi,

I have a macro coded as below:-

Sub LookupValues()

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Documents and Settings\Jac\Desktop\Book2.xls'
_myRange,2,0)"
Selection.AutoFill Destination:=Range("B1:B3")

End Sub

But this macro can only fill up the specific range with values which is
Range("B1:B3") but I wish that I could have the way that the macro can help
to fill up values for range with unknown length, which mean sometimes the
range could be longer or sometimes the length could be shorter.

I have tried out some methods but they seem like not working out as
expected. So someone please help to advise....

Thanking in advance.


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
Jac Jac is offline
external usenet poster
 
Posts: 58
Default Using Macro to fill up data in coulmn

hi, another thing regarding this macro module is that if the files to look up
for the values are different, how would I have to assign each file to the
macro?

I have tried out using input box to replace the file name(s) but the
directory will still remain, so is there any other way to do it? Please
advise........

Thanking in advance.


"Jac" wrote:

hi,

I have a macro coded as below:-

Sub LookupValues()

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'C:\Documents and Settings\Jac\Desktop\Book2.xls'
_myRange,2,0)"
Selection.AutoFill Destination:=Range("B1:B3")

End Sub

But this macro can only fill up the specific range with values which is
Range("B1:B3") but I wish that I could have the way that the macro can help
to fill up values for range with unknown length, which mean sometimes the
range could be longer or sometimes the length could be shorter.

I have tried out some methods but they seem like not working out as
expected. So someone please help to advise....

Thanking in advance.


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
List of data available for each cell within a coulmn BernzG Excel Worksheet Functions 4 March 30th 06 01:22 AM
Macro to transpose data to fill blank cells in table nospaminlich Excel Programming 5 October 29th 05 10:23 AM
Pls. reply Sort Data and copy to next coulmn when sort order chang shital shah Excel Programming 1 August 19th 05 02:51 PM
Sort Data and copy to next coulmn when sort data changes shital shah Excel Programming 0 August 18th 05 02:55 PM
Sort Data and copy to next coulmn when sort data changes shital shah Excel Programming 0 August 18th 05 06:48 AM


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

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

About Us

"It's about Microsoft Excel"