Insertar fila en tabla con vba

Victor Poketkrec

New Member
Joined
Jan 28, 2014
Messages
1
hola, soy nuevo en vba. voy aprendiendo poco a poco y tengo una duda en un caso real que quisiera solucionar. a ver si me explico:

en una tabla de datos tipo:
A B C
.
.
.
.
.
5 1 MANZANAS 23
6 2 PERAS 25
7
-------------
8 TOTAL 48

me gustaria hacer mediante vba que se insertara una fila nueva cada vez que rellenara los campos vacios, por ejemplo si relleno con NARANJAS 66 me lo dejara hacer en la fila 7 y añadiera una nueva fila en blanco para meter nuevos datos. (por lo tanto la fila total pasaria a ser la nueve

gracias de antemano.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Con algo asi:

El macro busca la palabra, "total" y agrega e inserta una fila arriba.


Sub test()
Dim frow As Long
Dim lrow As Long


frow = ActiveSheet.UsedRange.Cells(1).Row
lrow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row

For lrow = lrow To frow Step -1

If ActiveSheet.Cells(lrow, "b").Value = "total" Then
ActiveSheet.Cells(lrow, "b").EntireRow.Insert

End If
Next lrow


End Sub
 
Upvote 0

Forum statistics

Threads
1,222,951
Messages
6,169,211
Members
452,239
Latest member
fadhlatef

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top