473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Fixed number of columns - Variable number of rows in Excel

I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range.

Also, have never "posted" to a discussion

I have made a macro that works on a template spreadsheet with a fixed number of columns to be "macro'd" bounded by data that changes in its number of rows.

That is, the bounding data is imported to the spreadsheet before the calculated columns are run. But the rows of this data may be 20 rows or 2000 rows. My macros will always stop at the number of rows on which I recorded the data. That is, my example was 322 rows so now the 2000 row spreadsheet will only have 322 rows of 5 columns of calculated data. Obviously, I simply copy down and I get my desired result. But does your response dynamically adjust for differing number of rows?

when you responded to the person in the example below you wrote:

ya GL2:GL" & NbRows

Can you format that as a replacement to one of the questioner's lines please?

I have tried replacing the last Range line and I get an error

Range("GL2:GL2064").Select

changed to

Range("GL2:GL"& NbRows).Select

Simply, I want to be able to "copydown" 5 columns of calculating data based on adjoining rows that will be variable in number from spreadsheet to spreadsheet.


Thank you

Carol Locke


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

Dim varNbRows As Double

'Determine how many records are in the file
varNbRows = Selection.CurrentRegion.Rows.Count

Range("GL2").Select
ActiveCell.FormulaR1C1 = "=(RC[-106]/RC[-105])"
Range("GL2").Select
Selection.AutoFill Destination:=Range("GL2:GL2064"), Type:=xlFillDefault
Range("GL2:GL2064").Select

I need to change the 2064 with varNbRows-any suggestions?

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

Reply
iam_clint
Senior Member
168 Posts July 26th, 2006
07:22 PM
#2


Re: new to VB for Excel-cell range of a macro
--------------------------------------------------------------------------------

ya GL2:GL" & NbRows
__________________
- I reject your reality and substitute my own -
Oct 6 '06 #1
0 6163

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
7
by: Mel | last post by:
is there such thing ? using CSS ? thanks, Mel
17
by: Matt Kruse | last post by:
I'm looking for the best JS/CSS solution to add functionality to tables. The only browser which needs to be supported is IE5.5+, but no activeX can be used. to be able to do: - Fixed header row...
5
by: Johnny Meredith | last post by:
I have seven huge fixed width text file that I need to import to Access. They contain headers, subtotals, etc. that are not needed. There is also some corrupt data that we know about and can...
1
by: Luis Esteban Valencia | last post by:
Here is my aspx code: ============= <%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="PDM.excel.WebForm3" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
7
by: deep022in | last post by:
guys, I have written a perl script using Win32::OLe module. I was able to read it completly. but I have to specify the number of rows in excel sheet as command line option. I want to know how...
1
by: =?Utf-8?B?RGVicmEgTGFzc21hbg==?= | last post by:
I have installed Office 2007 on my machine and when I open Excel 2007 I still have 256 columns and 65,536 rows. I know in the 2007 version that you have the ability to have more than this. If I add...
0
by: Radu | last post by:
Hi. I'm trying to read the structure of some Excel 2000 file that the user is expected to upload. The file must be an excel file (solved) and it must contain a column named "PIN". That's all. Now...
0
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.