#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default Insert row

Excel 2003
I want to move data from one "InputSheet" to another "Calculation" sheet
that links to charts. I want to insert the data so that the chart ranges
expand, instead of having to set up the chart ranges ahead of time. Here's
the code i'm using now with the chart ranges set to 40 records.

Sub AddAshDataBtn()

'Update data on Process Runs Sheet based on new data entered on
AshDataEntry Sheet
ActiveWorkbook.Unprotect Password:="xxx"
Dim LDate As Date

Dim LAshDate As Date
Dim LName As String
Dim LComments As String
Dim LRPOT As Integer
Dim LP1C1WC As Integer
Dim LP1C2WC As Integer
Dim LP2C1WC As Integer
Dim LP2C2WC As Integer
Dim LP3C1WC As Integer
Dim LP3C2WC As Integer
Dim LP1C1POT As Integer
Dim LP1C2POT As Integer
Dim LP2C1POT As Integer
Dim LP2C2POT As Integer
Dim LP3C1POT As Integer
Dim LP3C2POT As Integer
ETC... (93 total Dims)

Dim LRow As Long
Dim LFound As Boolean

'Before adding new record, make sure a value was entered
If IsEmpty(Range("A4").Value) = False Then

'Retrieve new information
LAshDate = Range("A4").Value
LName = Range("C4").Value
LComments = Range("A36").Value
LRPOT = Range("E4").Value
LP1C1WC = Range("C9").Value
LP1C2WC = Range("C10").Value
LP2C1WC = Range("C11").Value
LP2C2WC = Range("C12").Value
LP3C1WC = Range("C13").Value
LP3C2WC = Range("C14").Value
LP1C1POT = Range("F9").Value
LP1C2POT = Range("F10").Value
LP2C1POT = Range("F11").Value
LP2C2POT = Range("F12").Value
LP3C1POT = Range("F13").Value
LP3C2POT = Range("F14").Value
ETC..


'Move to ProcessRuns Sheet to save the changes
Sheets("Process Runs").Visible = True
Sheets("Process Runs").Select
Sheets("Process Runs").Unprotect Password:="xxx"

LFound = False

LRow = 13

Do While LFound = False

'Encountered a blank record number (assuming end of list on
Records Sheet)
If IsEmpty(Range("AQ" & LRow).Value) = True Then
LFound = True
End If

LRow = LRow + 1
Loop

Range("AO" & LRow - 1).Value = LComments
Range("AP" & LRow - 1).Value = LRPOT
Range("AQ" & LRow - 1).Value = LAshDate
Range("AR" & LRow - 1).Value = LP1C1WC
Range("AS" & LRow - 1).Value = LP1C2WC
Range("AT" & LRow - 1).Value = LP2C1WC
Range("AU" & LRow - 1).Value = LP2C2WC
Range("AV" & LRow - 1).Value = LP3C1WC
Range("AW" & LRow - 1).Value = LP3C2WC
Range("AX" & LRow - 1).Value = LP1C1POT
Range("AY" & LRow - 1).Value = LP1C2POT
Range("AZ" & LRow - 1).Value = LP2C1POT
Range("BA" & LRow - 1).Value = LP2C2POT
Range("BB" & LRow - 1).Value = LP3C1POT
Range("BC" & LRow - 1).Value = LP3C2POT
ETC..



'Reposition back on AshDataEntry Sheet
Sheets("Process Runs").Protect Password:="xxx"
Sheets("Process Runs").Visible = False
Sheets("AshDataEntry").Select

'Clear entries from cells
Range("C4").Value = ""
Range("A36").Value = ""
Range("E4").Value = ""
Range("C9").Value = ""
Range("C10").Value = ""
Range("C11").Value = ""
Range("C12").Value = ""
Range("C13").Value = ""
Range("C14").Value = ""
Range("F9").Value = ""
Range("F10").Value = ""
Range("F11").Value = ""
Range("F12").Value = ""
Range("F13").Value = ""
Range("F14").Value = ""
ETC..

ActiveWorkbook.Save
MsgBox ("New Data was successfully added.")

ActiveWorkbook.Protect Password:="xxx"
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 168
Default Insert row

Gizmo,
If you use Excel 2003's "List" functionality, then the range your are
pointing to will automatically expand as new data is added to the "list".
--
Please remember to indicate when the post is answered so others can benefit
from it later.


"Gizmo" wrote:

Excel 2003
I want to move data from one "InputSheet" to another "Calculation" sheet
that links to charts. I want to insert the data so that the chart ranges
expand, instead of having to set up the chart ranges ahead of time. Here's
the code i'm using now with the chart ranges set to 40 records.

Sub AddAshDataBtn()

'Update data on Process Runs Sheet based on new data entered on
AshDataEntry Sheet
ActiveWorkbook.Unprotect Password:="xxx"
Dim LDate As Date

Dim LAshDate As Date
Dim LName As String
Dim LComments As String
Dim LRPOT As Integer
Dim LP1C1WC As Integer
Dim LP1C2WC As Integer
Dim LP2C1WC As Integer
Dim LP2C2WC As Integer
Dim LP3C1WC As Integer
Dim LP3C2WC As Integer
Dim LP1C1POT As Integer
Dim LP1C2POT As Integer
Dim LP2C1POT As Integer
Dim LP2C2POT As Integer
Dim LP3C1POT As Integer
Dim LP3C2POT As Integer
ETC... (93 total Dims)

Dim LRow As Long
Dim LFound As Boolean

'Before adding new record, make sure a value was entered
If IsEmpty(Range("A4").Value) = False Then

'Retrieve new information
LAshDate = Range("A4").Value
LName = Range("C4").Value
LComments = Range("A36").Value
LRPOT = Range("E4").Value
LP1C1WC = Range("C9").Value
LP1C2WC = Range("C10").Value
LP2C1WC = Range("C11").Value
LP2C2WC = Range("C12").Value
LP3C1WC = Range("C13").Value
LP3C2WC = Range("C14").Value
LP1C1POT = Range("F9").Value
LP1C2POT = Range("F10").Value
LP2C1POT = Range("F11").Value
LP2C2POT = Range("F12").Value
LP3C1POT = Range("F13").Value
LP3C2POT = Range("F14").Value
ETC..


'Move to ProcessRuns Sheet to save the changes
Sheets("Process Runs").Visible = True
Sheets("Process Runs").Select
Sheets("Process Runs").Unprotect Password:="xxx"

LFound = False

LRow = 13

Do While LFound = False

'Encountered a blank record number (assuming end of list on
Records Sheet)
If IsEmpty(Range("AQ" & LRow).Value) = True Then
LFound = True
End If

LRow = LRow + 1
Loop

Range("AO" & LRow - 1).Value = LComments
Range("AP" & LRow - 1).Value = LRPOT
Range("AQ" & LRow - 1).Value = LAshDate
Range("AR" & LRow - 1).Value = LP1C1WC
Range("AS" & LRow - 1).Value = LP1C2WC
Range("AT" & LRow - 1).Value = LP2C1WC
Range("AU" & LRow - 1).Value = LP2C2WC
Range("AV" & LRow - 1).Value = LP3C1WC
Range("AW" & LRow - 1).Value = LP3C2WC
Range("AX" & LRow - 1).Value = LP1C1POT
Range("AY" & LRow - 1).Value = LP1C2POT
Range("AZ" & LRow - 1).Value = LP2C1POT
Range("BA" & LRow - 1).Value = LP2C2POT
Range("BB" & LRow - 1).Value = LP3C1POT
Range("BC" & LRow - 1).Value = LP3C2POT
ETC..



'Reposition back on AshDataEntry Sheet
Sheets("Process Runs").Protect Password:="xxx"
Sheets("Process Runs").Visible = False
Sheets("AshDataEntry").Select

'Clear entries from cells
Range("C4").Value = ""
Range("A36").Value = ""
Range("E4").Value = ""
Range("C9").Value = ""
Range("C10").Value = ""
Range("C11").Value = ""
Range("C12").Value = ""
Range("C13").Value = ""
Range("C14").Value = ""
Range("F9").Value = ""
Range("F10").Value = ""
Range("F11").Value = ""
Range("F12").Value = ""
Range("F13").Value = ""
Range("F14").Value = ""
ETC..

ActiveWorkbook.Save
MsgBox ("New Data was successfully added.")

ActiveWorkbook.Protect Password:="xxx"
End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default Insert row

Thanks KC

I know how to set up the Named Ranges, but how would I Dim the Variables and
then refer to them in VBA?

Dim LName As ?
instead of
Dim LName As String

LName = Range("?").value
instead of
LName = Range("C4").Value

Range("?" & LRow - 1).Value = LName
instead of
Range("AO" & LRow - 1).Value = LName



"KC Rippstein" wrote:

Gizmo,
If you use Excel 2003's "List" functionality, then the range your are
pointing to will automatically expand as new data is added to the "list".
--
Please remember to indicate when the post is answered so others can benefit
from it later.


"Gizmo" wrote:

Excel 2003
I want to move data from one "InputSheet" to another "Calculation" sheet
that links to charts. I want to insert the data so that the chart ranges
expand, instead of having to set up the chart ranges ahead of time. Here's
the code i'm using now with the chart ranges set to 40 records.

Sub AddAshDataBtn()

'Update data on Process Runs Sheet based on new data entered on
AshDataEntry Sheet
ActiveWorkbook.Unprotect Password:="xxx"
Dim LDate As Date

Dim LAshDate As Date
Dim LName As String
Dim LComments As String
Dim LRPOT As Integer
Dim LP1C1WC As Integer
Dim LP1C2WC As Integer
Dim LP2C1WC As Integer
Dim LP2C2WC As Integer
Dim LP3C1WC As Integer
Dim LP3C2WC As Integer
Dim LP1C1POT As Integer
Dim LP1C2POT As Integer
Dim LP2C1POT As Integer
Dim LP2C2POT As Integer
Dim LP3C1POT As Integer
Dim LP3C2POT As Integer
ETC... (93 total Dims)

Dim LRow As Long
Dim LFound As Boolean

'Before adding new record, make sure a value was entered
If IsEmpty(Range("A4").Value) = False Then

'Retrieve new information
LAshDate = Range("A4").Value
LName = Range("C4").Value
LComments = Range("A36").Value
LRPOT = Range("E4").Value
LP1C1WC = Range("C9").Value
LP1C2WC = Range("C10").Value
LP2C1WC = Range("C11").Value
LP2C2WC = Range("C12").Value
LP3C1WC = Range("C13").Value
LP3C2WC = Range("C14").Value
LP1C1POT = Range("F9").Value
LP1C2POT = Range("F10").Value
LP2C1POT = Range("F11").Value
LP2C2POT = Range("F12").Value
LP3C1POT = Range("F13").Value
LP3C2POT = Range("F14").Value
ETC..


'Move to ProcessRuns Sheet to save the changes
Sheets("Process Runs").Visible = True
Sheets("Process Runs").Select
Sheets("Process Runs").Unprotect Password:="xxx"

LFound = False

LRow = 13

Do While LFound = False

'Encountered a blank record number (assuming end of list on
Records Sheet)
If IsEmpty(Range("AQ" & LRow).Value) = True Then
LFound = True
End If

LRow = LRow + 1
Loop

Range("AO" & LRow - 1).Value = LComments
Range("AP" & LRow - 1).Value = LRPOT
Range("AQ" & LRow - 1).Value = LAshDate
Range("AR" & LRow - 1).Value = LP1C1WC
Range("AS" & LRow - 1).Value = LP1C2WC
Range("AT" & LRow - 1).Value = LP2C1WC
Range("AU" & LRow - 1).Value = LP2C2WC
Range("AV" & LRow - 1).Value = LP3C1WC
Range("AW" & LRow - 1).Value = LP3C2WC
Range("AX" & LRow - 1).Value = LP1C1POT
Range("AY" & LRow - 1).Value = LP1C2POT
Range("AZ" & LRow - 1).Value = LP2C1POT
Range("BA" & LRow - 1).Value = LP2C2POT
Range("BB" & LRow - 1).Value = LP3C1POT
Range("BC" & LRow - 1).Value = LP3C2POT
ETC..



'Reposition back on AshDataEntry Sheet
Sheets("Process Runs").Protect Password:="xxx"
Sheets("Process Runs").Visible = False
Sheets("AshDataEntry").Select

'Clear entries from cells
Range("C4").Value = ""
Range("A36").Value = ""
Range("E4").Value = ""
Range("C9").Value = ""
Range("C10").Value = ""
Range("C11").Value = ""
Range("C12").Value = ""
Range("C13").Value = ""
Range("C14").Value = ""
Range("F9").Value = ""
Range("F10").Value = ""
Range("F11").Value = ""
Range("F12").Value = ""
Range("F13").Value = ""
Range("F14").Value = ""
ETC..

ActiveWorkbook.Save
MsgBox ("New Data was successfully added.")

ActiveWorkbook.Protect Password:="xxx"
End If

End 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
insert row / insert column command buttons fairgreen Excel Worksheet Functions 1 October 29th 07 02:41 PM
How can I insert a date with an icon (calendar) insert Alfredo Mederico[_2_] Excel Discussion (Misc queries) 4 September 21st 07 01:20 AM
Trying to insert a row. Insert wont Activate todflog1 Excel Worksheet Functions 6 July 30th 07 07:36 AM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
Insert Next? Or insert a variable number of records...how? Tom MacKay Excel Discussion (Misc queries) 0 April 20th 06 10:44 PM


All times are GMT +1. The time now is 02:45 PM.

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

About Us

"It's about Microsoft Excel"