Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default set a range thats not allways the same size.

Hi there,

I could use some help on the following problem.

I have this code to paste a formula to a range.
and it works!

ub Loop1()
Dim rListPaste As Range
Dim i As Long

Set rListPaste = Sheet3.Range("b2", "b1000")

' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"


End Sub

BUT

the range isnt allways till "b1000" it also can be 10 or 100.
so, how do i code this? i only want to copy the code to "where there
is data in collum A"

thanks in advance

kind regards

Sjoerd

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default set a range thats not allways the same size.


Sub Loop1()
Dim rListPaste As Range
Dim i As Long


'Set rListPaste = Sheet3.Range("b2", "b1000")
Set rListPaste = Sheet3.Range("b2", Range("B2").end(XlDown))


' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default set a range thats not allways the same size.

On 27 aug, 11:30, Excel_Expert wrote:
Sub Loop1()
Dim rListPaste As Range
Dim i As Long

'Set rListPaste = Sheet3.Range("b2", "b1000")
Set rListPaste = Sheet3.Range("b2", Range("B2").end(XlDown))

' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"

End Sub


Cheers m8, ill post the code when it works, i made some naste mistakes
there!

tnx

Sjoerd

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default set a range thats not allways the same size.

Not quite Excel_Expert..
OP was looking for filling column B until the last bit of data in column A
(not column B).
Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)
or
Set rListPaste = Sheet3.Range("b2", "b" & Range("A" &
Rows.Count).End(xlUp).Row)

(that second one's only one line btw)

--
p45cal


"Excel_Expert" wrote:


Sub Loop1()
Dim rListPaste As Range
Dim i As Long


'Set rListPaste = Sheet3.Range("b2", "b1000")
Set rListPaste = Sheet3.Range("b2", Range("B2").end(XlDown))


' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"

End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default set a range thats not allways the same size.

On 27 aug, 11:52, p45cal wrote:
Not quite Excel_Expert..
OP was looking for filling column B until the last bit of data in column A
(not column B).
Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)
or
Set rListPaste = Sheet3.Range("b2", "b" & Range("A" &
Rows.Count).End(xlUp).Row)

(that second one's only one line btw)

--
p45cal



"Excel_Expert" wrote:

Sub Loop1()
Dim rListPaste As Range
Dim i As Long


'Set rListPaste = Sheet3.Range("b2", "b1000")
Set rListPaste = Sheet3.Range("b2", Range("B2").end(XlDown))


' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"


End Sub- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -

This piece of code works!
thanks very much

this is wat it is now...

Sub Loop1()
Dim rListPaste As Range

Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)

' This loop runs until there is nothing in the last column
Do
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))

End Sub

so i can copy a formula to vlookup cells in col. a.

thanks!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default set a range thats not allways the same size.

try removing the following 3 lines and see if it still does what you want:
Do
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
--
p45cal


" wrote:

On 27 aug, 11:52, p45cal wrote:
Not quite Excel_Expert..
OP was looking for filling column B until the last bit of data in column A
(not column B).
Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)
or
Set rListPaste = Sheet3.Range("b2", "b" & Range("A" &
Rows.Count).End(xlUp).Row)

(that second one's only one line btw)

--
p45cal



"Excel_Expert" wrote:

Sub Loop1()
Dim rListPaste As Range
Dim i As Long


'Set rListPaste = Sheet3.Range("b2", "b1000")
Set rListPaste = Sheet3.Range("b2", Range("B2").end(XlDown))


' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"


End Sub- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -

This piece of code works!
thanks very much

this is wat it is now...

Sub Loop1()
Dim rListPaste As Range

Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)

' This loop runs until there is nothing in the last column
Do
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))

End Sub

so i can copy a formula to vlookup cells in col. a.

thanks!


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default set a range thats not allways the same size.

On 27 aug, 13:04, p45cal wrote:
try removing the following 3 lines and see if it still does what you want:
Do
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
--
p45cal



" wrote:
On 27 aug, 11:52, p45cal wrote:
Not quite Excel_Expert..
OP was looking for filling column B until the last bit of data in column A
(not column B).
Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)
or
Set rListPaste = Sheet3.Range("b2", "b" & Range("A" &
Rows.Count).End(xlUp).Row)


(that second one's only one line btw)


--
p45cal


"Excel_Expert" wrote:


Sub Loop1()
Dim rListPaste As Range
Dim i As Long


'Set rListPaste = Sheet3.Range("b2", "b1000")
Set rListPaste = Sheet3.Range("b2", Range("B2").end(XlDown))


' This loop runs until there is nothing in the next column
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"


End Sub- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -

This piece of code works!
thanks very much


this is wat it is now...


Sub Loop1()
Dim rListPaste As Range


Set rListPaste = Sheet3.Range("b2", "b" & Range("A2").End(xlDown).Row)


' This loop runs until there is nothing in the last column
Do
rListPaste.Formula = "=VLOOKUP(Sheet1!$A2,FIXEL!$B:$C,2,)"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))


End Sub


so i can copy a formula to vlookup cells in col. a.


thanks!- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven -


Cheers!
this is the answer :-)


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
Allways Display in Caps Letter Indhu . K Excel Discussion (Misc queries) 1 March 2nd 09 09:39 AM
Autofilter not allways working Excel 2003 HB Excel Worksheet Functions 1 March 1st 09 11:19 PM
Allways on top Sara Excel Discussion (Misc queries) 4 May 8th 07 09:41 AM
why does the office update program allways fail fae Setting up and Configuration of Excel 0 October 8th 05 02:06 AM
How can I allways paste PLAIN TEXT ? Davus_ik Excel Discussion (Misc queries) 2 January 9th 05 03:55 PM


All times are GMT +1. The time now is 03:53 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"