Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Excel Functions for Records

I have a spreadsheet that has a different number of rows every week. Based on
the number of rows, I would like excel to perform functions such as Vlookup
and Days 360, in the empty columns. How do I get the functions to appear only
when there are records in the corresponding columns? Here is what I have. Not
sure where I should insert where to put my formulas and how ?


Worksheets("ARO").Unprotect

With Sheets("ARO")
Range("B8").CopyFromRecordset RST
End With
DoEvents

RST.Close

Worksheets("ARO").Protect
DoEvents

Worksheets("ARO").Unprotect
Sheets("ARO").Select
Cells(2, 1).Value = "Report has been succesfully updated"
DoEvents
Cells(2, 1).Font.ColorIndex = 1
DoEvents
Cells(2, 1).Font.Bold = True
DoEvents
Worksheets("ARO").Protect

Exit Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Excel Functions for Records

The easy solution is to use the Recordset.RecordCount property to find the
number of rows in the recordset; then you can loop through those rows and
copy the formulas; e.g.

RSTCount = RST.RecordCount
With Sheets("ARO")
.Unprotect ' you may as well put this inside the With... End With
.Range("C8").Copy 'assumes a formula in C8 that you want copied down
' assume you need the dot here before Range:
.Range("B8").CopyFromRecordset RST
For i = 1 to RSTCount-1
.Range("C8").Offset(i,0).PasteSpecial xlPasteAll
Next i
DoEvents
RST.Close
.Protect
End With

--
- K Dales


"marthasanchez" wrote:

I have a spreadsheet that has a different number of rows every week. Based on
the number of rows, I would like excel to perform functions such as Vlookup
and Days 360, in the empty columns. How do I get the functions to appear only
when there are records in the corresponding columns? Here is what I have. Not
sure where I should insert where to put my formulas and how ?


Worksheets("ARO").Unprotect

With Sheets("ARO")
Range("B8").CopyFromRecordset RST
End With
DoEvents

RST.Close

Worksheets("ARO").Protect
DoEvents

Worksheets("ARO").Unprotect
Sheets("ARO").Select
Cells(2, 1).Value = "Report has been succesfully updated"
DoEvents
Cells(2, 1).Font.ColorIndex = 1
DoEvents
Cells(2, 1).Font.Bold = True
DoEvents
Worksheets("ARO").Protect

Exit Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete records when certain records have duplicate column data JVroom New Users to Excel 1 January 26th 09 06:23 PM
draw 999 x 8 random records from file with 8614 records news.wanadoo.nl Excel Programming 1 March 1st 06 03:04 PM
how can I use functions limited to selected records when autofilte okhameed Excel Discussion (Misc queries) 1 August 30th 05 12:31 PM
Expand Excel to more than 65,536 records - please! Max Excel Discussion (Misc queries) 6 May 25th 05 07:12 PM
excel functions and User defined functions Kanan Excel Programming 4 May 20th 04 11:21 PM


All times are GMT +1. The time now is 07:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"