473,654 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fixed number of columns - Variable number of rows in Excel

1 New Member
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:GL20 64").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.Curre ntRegion.Rows.C ount

Range("GL2").Se lect
ActiveCell.Form ulaR1C1 = "=(RC[-106]/RC[-105])"
Range("GL2").Se lect
Selection.AutoF ill Destination:=Ra nge("GL2:GL2064 "), Type:=xlFillDef ault
Range("GL2:GL20 64").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 6180

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

Similar topics

5
3185
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 to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
7
18737
by: Mel | last post by:
is there such thing ? using CSS ? thanks, Mel
17
3678
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 - Data sorting (preferrably intelligently determining data type based on content) - If possible, locking the first column from scrolling
5
11565
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 correct once the data is in Access (or during the import process itself). Furthermore, the text files are poorly set up, such that some records may be "shifted" over a few characters, and therefore the fixed width nature of the file is corrupted. ...
1
1857
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 Transitional//EN" > <HTML> <HEAD> <title>WebForm3</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE">
7
42657
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 to retrieve number of rows of the excel sheet and number of columns also. i tried to retrieve the properties using the each methode. see below
1
3063
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 new rows and colulmns it will not insert any additional ones. If I open a workbook that someone else has created in Excel 2007 I see over 1,000,000 rows and more than 256 columns. How do I add these additional rows to my new workbooks in 2007?...
0
2327
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 about the column name. I have the code: cnExcel.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strTableName & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
0
2992
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 VBA code. The following is the Access VBA code I used to delete blank columns and rows in the excel file. But, unfortunately, the resultant excel file still has two columns (C and D) grouped together, so when I am importing the file to MS Access,...
0
8379
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.