Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code need help on CopyPaste

I have a list of PartNumber ranging from B2:B6880 and I am vlooking them
up to other worksheets for values of Safety-Stock, Qty-on-hand, PO-Qty,
etc..

For example, I insert column N to vlookup for the Safety-Stock values.
Double-clicking the black cross-sign that appears on the bottom-right
of cell N2 Vlookup formula doesn't copy the N2 formula to N6880 because
there are some blank cells in column M and column O.

I am hoping someone can help me with a code which can allow to copy
cell N2 formula to the last cell in column N where the whole row is not
totally blank, ie. at least has a cell in the row populated with
value.
Eg, if this row as mentioned above is row 6880, then row 6881 onwards
will be totally blank.


Appreciate so much if someone can help with with a code to do this.
Thanks so much in advance!


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default VBA code need help on CopyPaste

The simple solution would be to drag the formula down. However, if you want
a macro solution:

Sub CopyToEnd() 'untested
Dim LastRow As Long
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("N2").Copy Range("N3:N" & LastRow)
End Sub

--

Vasant

"alienscript" wrote in message
...
I have a list of PartNumber ranging from B2:B6880 and I am vlooking them
up to other worksheets for values of Safety-Stock, Qty-on-hand, PO-Qty,
etc..

For example, I insert column N to vlookup for the Safety-Stock values.
Double-clicking the black cross-sign that appears on the bottom-right
of cell N2 Vlookup formula doesn't copy the N2 formula to N6880 because
there are some blank cells in column M and column O.

I am hoping someone can help me with a code which can allow to copy
cell N2 formula to the last cell in column N where the whole row is not
totally blank, ie. at least has a cell in the row populated with
value.
Eg, if this row as mentioned above is row 6880, then row 6881 onwards
will be totally blank.


Appreciate so much if someone can help with with a code to do this.
Thanks so much in advance!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code need help on CopyPaste

Hi Vasant,

Thanks for your help.

What if in stead of selecting this:

Range("N2").Copy Range("N3:N" & LastRow)

I want to randomly select any cells in row 2 to CopyToEnd, how can I
use the Selection in ActiveSheet to do this job ?

Thanks in advance for help.


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code need help on CopyPaste

Hi alienscript


Code:
--------------------


Dim col As Long
col = ActiveCell.Column
Range(Cells(2, col), Cells(Rows.Count, col).End(xlUp)).Formula = _
Cells(2, col).Formula


--------------------



---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code need help on CopyPaste

Hi Colo,

I placed my cursor at Cell M2 that has a formula and run the code belo
but it doesn't copy down the formula !

Is there something missing from your code ?
Hope you can help. Thanks.


Sub Cell2CopyToEnd()

Dim col As Long
col = ActiveCell.column
Range(Cells(2, col), Cells(Rows.Count, col).End(xlUp)).Formula = _
Cells(2, col).Formula

End Su

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code need help on CopyPaste

Hi

Let me know one thing pls. how can i know the last row.? I mean which
column should be based for getting the last row?


---
Message posted from http://www.ExcelForum.com/

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM


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