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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
The reason I am asking is because I made up some data to test with and it produces results from Left to right.

Book1
ABCDEFGHIJK
1
2ChicagoFaroe IslandsDN3463ChicagoFaroe IslandsDN3463
3LuxembourgAnyPlaceTest12
4WarsawFaroe IslandsBC3497WarsawFaroe IslandsBC3497
5AnyCityAnyPlaceTest12
6LuxembourgFaroe IslandsBF6959LuxembourgFaroe IslandsBF6959
7ChicagoDusseldorfHK9783ChicagoDusseldorfHK9783
8WarsawDusseldorfVC1015WarsawDusseldorfVC1015
9AnyCityAnyPlaceTest12
10LuxembourgAnyPlaceTest12
Sheet1
 
Upvote 0
Any idea what could cause my problem? Maybe a setting or something that isnt turned on?
 
Upvote 0
Your tests are all case sensitive, if that could be the problem?
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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