-3

I need to find the number of rows in a column of Excel and minus one of the total rows. And assign this numeric value to variable. Example: Column A has data in 10 rows. Now using VBA script I should be able to find the total number of rows. Total rows in column A is 10. Then total minus 1. 10-1=9 And this 9 has to be assigned to a variable and shd be written in the excel sheet. X is 9 . The x value is 9 and it should get stored in column B as 009.

Suppose if X value is 38, it should get stored as 038 in column B

Please suggest the best possible way.

Community
  • 1
  • 1
Sai
  • 97
  • 1
  • 2
  • 12

1 Answers1

1

Check out this website for finding the last row using VBA, then simply subtract 1 from your total row count

Check out this website for formatting cells using VBA

FYI, this literally took me 10 seconds to Google these answers... you're welcome

Maldred
  • 1,074
  • 4
  • 11
  • 33
  • @Sai, have a look at https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-vba/11169920#11169920, where you'll find an interesting overview "Unreliable ways of finding last used cell". BTW, SO participation demands a question that summarizes the specific problem (stackoverflow.com/help/how-to-ask) as well as a minimum of time invested by yourself instead of others (e.g. code examples so far). – T.M. Nov 02 '17 at 16:47