Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Put a value into variable

Hi,

I have declared a variable as Integer, and I am trying to
put a value into it, but it will not work.
Is the sentence below wrong?? When I use F8 the value of
the cell is 0.3..but it will not be transferred into
PVK....what is wrong?

PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value

Does anyone have a clue on this one?
Help is highly appreciated...

Gunnar
------
here is the total code

Sub FindPVC()

Dim Produkt1 As Long
Dim Produkt2 As Long
Dim PasteRow As Integer
Dim ProduktRad1 As Long
Dim ProduktRad2 As Long
Dim PVK As Integer

Dim ShtFlasker As Worksheet
Set ShtFlasker = Sheets("Flasker")

Dim ShtMatrise As Worksheet
Set ShtMatrise = Sheets("Matrise")

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False

ShtFlasker.Activate
ProduktRad1 = 6
ProduktRad2 = 13
PasteRow = 6
Produkt1 = Range("F" & ProduktRad1).Value 'legger inn
mat.# i flasker

For Each c In Range("ProduktListe")
ShtMatrise.Activate

Produkt2 = Range("C" & ProduktRad2).Value 'legger inn
mat# i matrise arket

Do While Produkt1 = Produkt2 ' viss match
'ShtMatrise.Activate
PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value '
hente PVk verdi

Selection.Copy
ShtFlasker.Range("T" & PasteRow) = PVK ' overfør
verdien

PasteRow = PasteRow + 1 ' øk med en
ProduktRad1 = ProduktRad1 + 1

Loop
ProduktRad2 = ProduktRad2 + 1
Next c
'ProduktRad1 = ProduktRad1 + 1
Application.ScreenUpdating = True
MsgBox "Finished!"
End Sub








  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Put a value into variable

PVK is declared as an integer. The value you suggested is a decimal. Try
declaring PVK as a Single.

cheers,
Matt.

"Gunnar" wrote in message
...
Hi,

I have declared a variable as Integer, and I am trying to
put a value into it, but it will not work.
Is the sentence below wrong?? When I use F8 the value of
the cell is 0.3..but it will not be transferred into
PVK....what is wrong?

PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value

Does anyone have a clue on this one?
Help is highly appreciated...

Gunnar
------
here is the total code

Sub FindPVC()

Dim Produkt1 As Long
Dim Produkt2 As Long
Dim PasteRow As Integer
Dim ProduktRad1 As Long
Dim ProduktRad2 As Long
Dim PVK As Integer

Dim ShtFlasker As Worksheet
Set ShtFlasker = Sheets("Flasker")

Dim ShtMatrise As Worksheet
Set ShtMatrise = Sheets("Matrise")

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False

ShtFlasker.Activate
ProduktRad1 = 6
ProduktRad2 = 13
PasteRow = 6
Produkt1 = Range("F" & ProduktRad1).Value 'legger inn
mat.# i flasker

For Each c In Range("ProduktListe")
ShtMatrise.Activate

Produkt2 = Range("C" & ProduktRad2).Value 'legger inn
mat# i matrise arket

Do While Produkt1 = Produkt2 ' viss match
'ShtMatrise.Activate
PVK = ShtMatrise.Range("BJ" & ProduktRad2).Value '
hente PVk verdi

Selection.Copy
ShtFlasker.Range("T" & PasteRow) = PVK ' overfør
verdien

PasteRow = PasteRow + 1 ' øk med en
ProduktRad1 = ProduktRad1 + 1

Loop
ProduktRad2 = ProduktRad2 + 1
Next c
'ProduktRad1 = ProduktRad1 + 1
Application.ScreenUpdating = True
MsgBox "Finished!"
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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
How to graph x-variable versus y-variable in Excel ? Mojjara New Users to Excel 3 April 2nd 09 05:38 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


All times are GMT +1. The time now is 07:25 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"