Benvenuto Ospite Cerca | Topic Attivi | Utenti | | Log In | Registra

Macro excel copia incolla e fermati Opzioni
svinti
Inviato: Thursday, March 15, 2012 4:29:30 PM
Rank: Newbie

Iscritto dal : 3/15/2012
Posts: 1
Copy & paste a cell value on every row of a new column until You reach an empty row

Hi all!

I need help to finish to produce a macro that does the following:
a - copy a value (which is always in the A2 Cell);
b - insert a new column at the beginning of the sheet (col A);
c - paste the value (step a) in every row of the newly born column (step b) and stops pasting when the rows ar not populated anymore.

A little step backward.....

I've already created a macro that erases all the empty rows (unfortunately it is NOT a table but a kind of invoice converted in an excel file); then I've created the code to copy the value, to insert the column and now I need to stop the loop as soon as the cell in column B starts to be empty.

EXAMPLE (original file):

A B C D E F G
1 1 22 d 31 gg tr
2 36855 2 77 e 59 bb es
3 5 22 g 14 nn nm
4 7 33 o 27 ed lp
5
6


EXAMPLE (new column inserted):
A B C D E F G
1 36855 1 22 d 31 gg tr
2 36855 36855 2 77 e 59 bb es
3 36855 5 22 g 14 nn nm
4 36855 7 33 o 27 ed lp
5 STOP
6


So it shall paste the value A2 in the newly created A column 'yil B* is NOT NULL

i would really appreciate any help !

Sponsor
Inviato: Thursday, March 15, 2012 4:29:30 PM

 
a10n11
Inviato: Friday, March 16, 2012 11:22:48 AM

Rank: AiutAmico

Iscritto dal : 5/29/2003
Posts: 1,694
salve (Hello)
try this

Sub test()
myvalue = Range("A2").Value
Lrow = Range("A" & Rows.Count).End(xlUp).Row
Columns("A:A").Insert Shift:=xlToRight
For n = 1 To Lrow
Cells(n, 1).Value = myvalue
Next n
End Sub


saluti
Giap

Utenti presenti in questo topic
Guest


Salta al Forum
Aggiunta nuovi Topic disabilitata in questo forum.
Risposte disabilitate in questo forum.
Eliminazione tuoi Post disabilitata in questo forum.
Modifica dei tuoi post disabilitata in questo forum.
Creazione Sondaggi disabilitata in questo forum.
Voto ai sondaggi disabilitato in questo forum.

Main Forum RSS : RSS

Aiutamici Theme
Powered by Yet Another Forum.net versione 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.