An exact solution representing black holes in an expanding universe is found. The black holes are maximally charged and the universe is expanding with arbitrary equation of state. It is an exact solution of the Einstein-scalar-Maxwell system, in which we have two Maxwell-type U(1) fields coupled to the scalar field. The potential of the scalar field is an exponential. The solution depends on two parameters, the charge Q and one parameter (the ratio of the energy density of U(1) fields to that of the scalar field). We find a regular horizon, which is static because of the balance on the horizon between gravitational attractive force and U(1) repulsive force acting on the scalar field. We also calculate the black hole temperature. For the case without a potential, we can derive such a solution from a time-dependent intersecting M-brane solution in eleven dimensions by the dimensional reduction.