Can't output values to cell

John787878

New Member
Joined
Aug 11, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have tried everything, but my code just won't work:

VBA Code:
Option Explicit

Sub Fly()


    
    Dim r As Integer
    Dim c As Integer
    Dim Number As Single
    Number = 10002
    ReDim Flylist(1 To Number, 1 To 3) As String
    
 
    
    For r = 1 To Number
        For c = 1 To 3
            Flylist(r, c) = Cells(r + 1, c)
        Next c
    Next r
    
    For r = 1 To Number
        For c = 1 To 3
            If ((Cells(r + 1, 1) = "Luxembourg") Or (Cells(r + 1, 1) = "Warsaw") Or (Cells(r + 1, 1) = "Chicago")) _
            And ((Cells(r + 1, 2) = "Dusseldorf") Or (Cells(r + 1, 2) = "Faroe Islands")) Then
                
            Cells(r + 1, c + 8) = Flylist(r, c)
            End If
        Next c
    Next r
End Sub

It should output following:

Chicago
Faroe Islands
DN3463

Warsaw
Faroe Islands
BC3497

Luxembourg
Faroe Islands
BF6959

Chicago
Dusseldorf
HK9783

Warsaw
Dusseldorf
VC1015

Pls help!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Case sensitive means that Warsaw does not equal warsaw, which does not equal WARSAW
 
Upvote 0
How is it appearing?
I want the following to appear on the worksheet:

Chicago
Faroe Islands
DN3463

Warsaw
Faroe Islands
BC3497

Luxembourg
Faroe Islands
BF6959

Chicago
Dusseldorf
HK9783

Warsaw
Dusseldorf
VC1015

It works when i type debug.print Flylist(r,c)
 
Upvote 0
That does not answer my question.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Can't output values to cell
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
I am sorry about that, i will read the forum rules. But the code i have written saves 10000 different flights, all with a departure city, arravial city and flight number. The code should then take all flght that have following departure cities:

Warsaw, chicago and Luxembourg

and find flights that arive in the following cities

Faroe island

Duseldorf.

With the use of the debug.print command, the following flights appeared in the immidiate window:

Chicago
Faroe Islands
DN3463

Warsaw
Faroe Islands
BC3497

Luxembourg
Faroe Islands
BF6959

Chicago
Dusseldorf
HK9783

Warsaw
Dusseldorf
VC1015

My question is why it won't post these flights in the specified cells:
Cells(r + 1, c + 8) = Flylist(r, c)

Hope this answers your question, and again sorry for the cross-posting
 
Upvote 0
Is your data in the format as JohnnyL posted in post#3?
 
Upvote 0
And once again, what is the code doing now?
 
Upvote 0
Writting the found flights in Cells(r + 1, c + 8), but its not working. The cells are blank
 
Upvote 0

Forum statistics

Threads
1,216,456
Messages
6,130,743
Members
449,588
Latest member
accountant606

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top