ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro for text file with different size (https://www.excelbanter.com/excel-programming/353430-macro-text-file-different-size.html)

Karolina

Macro for text file with different size
 

I have to create a macro which consists on importing a text file and
give some format. However the same text file can change its size. The
problem I have is that after creating a macro for example with 20 rows,
and I add more rows to the text file, if I run the macro again it will
not recognize more than the 20 rows used originally to create the
macro.

How can I customize the macro to take the amount of rows that are
present in the text every time I have to run it.

Hope somebody can help me with this.

Thanks in advance,
Karolina


--
Karolina
------------------------------------------------------------------------
Karolina's Profile: http://www.excelforum.com/member.php...o&userid=31600
View this thread: http://www.excelforum.com/showthread...hreadid=512902


Dave Peterson

Macro for text file with different size
 
Depends on what you're doing, but you could use:

dim lastrow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
' Then you can use that in your code:

.range("a1:x" & lastrow).somethinghere

end with




Karolina wrote:

I have to create a macro which consists on importing a text file and
give some format. However the same text file can change its size. The
problem I have is that after creating a macro for example with 20 rows,
and I add more rows to the text file, if I run the macro again it will
not recognize more than the 20 rows used originally to create the
macro.

How can I customize the macro to take the amount of rows that are
present in the text every time I have to run it.

Hope somebody can help me with this.

Thanks in advance,
Karolina

--
Karolina
------------------------------------------------------------------------
Karolina's Profile: http://www.excelforum.com/member.php...o&userid=31600
View this thread: http://www.excelforum.com/showthread...hreadid=512902


--

Dave Peterson


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com